Skip to content

Instantly share code, notes, and snippets.

@rohitdholakia
Created December 2, 2013 01:33
Show Gist options
  • Save rohitdholakia/7743559 to your computer and use it in GitHub Desktop.
Save rohitdholakia/7743559 to your computer and use it in GitHub Desktop.
Accepted answers for tags
from __future__ import division
from collections import defaultdict
accepted_answers_for_tags = defaultdict(int)
count = 0
for key in question_details.iterkeys():
if question_details[key]['acceptedId']:
for t in question_details[key]['tags']:
accepted_answers_for_tags[t] += 1
percentages = []
for key, value in dict(sorted(accepted_answers_for_tags.iteritems(), key = lambda x: x[1], reverse = True)[:20]).iteritems():
percentages.append((key, tags_dict[key], (value/tags_dict[key])*100))
print sorted(percentages, key = lambda x: x[2], reverse = True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment