0

I have a small data set of all the retweets in Mongodb. I want to count the average retweet of all the tweets.

I can do that in Python but I was wondering if I can do that in one command in Mondodb.

This is what I have got so far.

db.getCollection('raw_tweets').aggregate([
    {"$group" : {_id:"$retweeted_status.id_str", count:{$sum:1}}}
])

This would count all the retweets. However, I want to average that number. Not sure if it's possible?

toy
  • 11,711
  • 24
  • 93
  • 176
  • You did "some" research. So how did you possibly miss the [`$avg`](http://docs.mongodb.org/manual/reference/operator/aggregation/avg/) accumulator? – Blakes Seven Sep 04 '15 at 14:05
  • possible duplicate of [Calculate the average value of a mongodb document](http://stackoverflow.com/questions/29756262/calculate-the-average-value-of-a-mongodb-document) – Blakes Seven Sep 04 '15 at 14:06

0 Answers0