I try to query the average of 'clicks' from MongoDB database using PyMongo.
query_result = list(my_collection.aggregate([{'$group' : {'_id' : None, 'avg_clicks': {'$avg' : "$clicks"}}}]))
The result of the query is:
ok
result
Do you know what can be the problem?
Collection.aggregate returns a dictionary like
{'ok': 1 or 0, 'result': the_actual_result}
Thus
list(my_collection.aggregate(...))
iterates over the dictionary, getting the list of keys ['ok', 'result'].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With