Код: Выделить всё
Q1 Q2 Q3 Q4 Q5 Q6
0 Occasionally Agree Agree comment comment Very Well
1 Frequently Agree Agree NaN NaN Moderately
2 Frequently Agree Agree NaN NaN Well
3 Frequently Agree Neither Agree nor Disagree comment comment Moderately
Код: Выделить всё
def read_responses(xl):
responses = []
action = False
data = pd.read_excel(xl)
for name, values in data.items():
if name.endswith("?"):
action = True
if action == True:
data_set = {}
set = values.value_counts(dropna=True).to_dict()
labels, data = list(set.keys()), list(set.values())
data_set['question'] = name
data_set['type'] = id_type(labels)
data_set["responses"] = labels
data_set["values"] = data
responses.append(data_set)
build_chart(responses)
В конце концов, это передается в мою функцию построения графика:
Код: Выделить всё
[{'question': 'Q1',
'type': 'likert',
'responses': [Agree],
'values':[4]
}]
Код: Выделить всё
def id_type(response):
type = 'comment'
for scale in scales:
for term in scale:
if term == response[0]: type = 'likert'
return type
Я чувствую, что это уже довольно скудно, но я хочу проверить работоспособность, чтобы увидеть, существует ли более устоявшийся или общепринятый способ оценки опросов?
Подробнее здесь: https://stackoverflow.com/questions/798 ... -efficient
Мобильная версия