| import csv | |
| """ | |
| 0 First I heard of this hack | |
| 1 I feel I should try this hack, but have never actually tried it | |
| 2 I tried this hack with disappointing results | |
| 3 I tried this hack with good results, but it stopped working | |
| 4 I tried this hack with good results, and I don't use it consistently, though I'd like to | |
| 5 I tried this hack with good results, and now use it consistently | |
| 6 I don't think this hack is worth trying | |
| 7 Write-in answer in PiratePad or reply comment | |
| """ | |
| reports = [ | |
| [[1, 4], [1, 2, 3, 4, 5], "p(hack akrasia|heard of hack and thought it was worth trying)"], | |
| [[5], [1, 2, 3, 4, 5], "p(using hack profitably|heard of hack and thought it was worth trying)"], | |
| [[4, 5], [2, 3, 4, 5], "p(hack seems to work|tried hack)"], | |
| [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6], "p(hack seeemed worth trying|heard of hack)"], | |
| ] | |
| with open('productivity-survey.csv', 'r') as infile: | |
| reader = csv.reader(infile) | |
| lines = [line for line in list(reader) if not line[0].startswith('#')] | |
| for report in reports: | |
| for poll_id in ('219', '220', '221', '222'): | |
| print(poll_id) | |
| responses = [line[2] for line in lines if line[1] == poll_id] | |
| response_freq = {} | |
| for response in responses: | |
| response_freq[response] = response_freq.get(response, 0) + 1 | |
| print(report[2]) | |
| print(sum(response_freq[str(i)] for i in report[0]) * 1.0 / sum(response_freq[str(i)] for i in report[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment