I have an issue with the Average function in pymongo aggregate query.
I have a structure like this:
{'_id': ObjectId('5afd9c675e3a1f0e9b830510'),
'actor_gender': 'NaN',
'actor_id': 'NaN',
'actor_last_name': 'Safary',
'actor_name': 'Darsheel',
'actor_role': 'NaN',
'director_id': 'NaN',
'director_last_name': 'Khan',
'director_name': 'Aamir',
'movie_genre': 'Drama',
'movie_name': 'Taare Zameen Par',
'movie_rank': 8.5,
'movie_year': 2007}
When I compute this query:
coll.aggregate([{"$group":{"_id":{"movie_genre":"Drama"},
"avg":{"$avg":"$movie_rank"}}}])
I got this nan
on the average:
{'_id': {'movie_genre': 'Drama'}, 'avg': nan}
具有nan值的Mongodb聚合将NAN作为输出( https://jira.mongodb.org/plugins/servlet/mobile#issue/SERVER-27472 )您必须在movie_rank字段中具有一些nan值。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.