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]:
community proportion
category
business 5 4.0
culture-recreation 34 27.2
life-arts 19 15.2
professional 4 3.2
science 15 12.0
technology 48 38.4