I started learning to use MongoDB along with Jupyter notebook and the python module Pymongo.
In one of my documents, I store data as following:
{
"_id" : ObjectId("60b78821d5a53a1f12336580"),
"num_arete" : "0",
"date" : ISODate("2020-01-01T07:01:00Z"),
"nb_vehicules" : "32"
}
I wanted, using aggregation, make the $sum of all the nb_vehicules within the document's collecions group by date.
Here's what I've tried:
passage_per_hour = collection_trafic.aggregate([{
'$group': {
'_id': '$date',
'amount': { '$sum': {'$toInt' :'$nb_vehicules'}}
}
}])
But when I run it inside the notenook, it doesn't perfom the group-by and display me $date as None (see below).
Do someone has any idea why ?