In [1]:
from __future__ import division
import pymongo, pandas, random
client = pymongo.MongoClient('localhost', 27017)
results_db = client['results']['question_1']
In [2]:
cursor = results_db.find({},
{u'_id': False, u'community':True,'category': True})
df = pandas.DataFrame(list(cursor))
In [9]:
df_count = df.groupby('category').count()
df_count['proportion'] = 100*(df_count.community/125)
df_count
Out[9]: