twitter data-set

{
	"_id" : ObjectID("xxxx"),
	"text" : "Something interesting ...",
	"entities" : {
		"user_mentions" : [
			{
				"screen_name" : "somebody_else",
				...
			}
		],
		"urls" : [],
		"hashtags": []
	},
	"user" : {
		"friends_count" : 544,
		"screen_name" : "somebody",
		"followers_count" : 100,
	}
}
from pymongo import MongoClient
import pprint

client = MongoClient("mongodb://localhost:27017")
db = client.twitter

def most_tweets():
	result = db.tweets.aggregate([
			{ "$group" : {"_id" : "$user.screen_name",
				"count": {"$sum" : 1}}},
			{ "$sort" : {"count" : -1 }}
		])
	return result

if __name__ == '__main__':
	result = most_tweets()
	pprint.pprint(result)