Skip to content

Instantly share code, notes, and snippets.

@RomanSteinberg
Created November 29, 2018 14:06
Show Gist options
  • Save RomanSteinberg/65484d81b7ab8afb741ed14823121d7f to your computer and use it in GitHub Desktop.
Save RomanSteinberg/65484d81b7ab8afb741ed14823121d7f to your computer and use it in GitHub Desktop.
TypeForm Analyze
import pandas as pd
import json
# input parameters
quiz_res_file = '/home/roman/temp/pre_survey/quiz_result.csv'
quiz_descr_file = '/home/roman/temp/pre_survey/quiz_description.json'
# main
df = pd.read_csv(quiz_res_file)
description = json.load(open(quiz_descr_file))
data = {}
for ind, pair_descr in enumerate(description):
pair_type = pair_descr['type']
if pair_type not in data.keys():
data[pair_type] = []
raw_rates = df.iloc[:, ind+1].tolist()
rates_without_nan = [x for x in raw_rates if x == x]
data[pair_type] += rates_without_nan
for pair_type, rates in data.items():
# print(rates)
print('Global average for %s is %f' % (pair_type, round(sum(rates) / len(rates), 2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment