{
"GU" : "Person2",
"CW" : 2,
"Year" : 2015,
"_id" : "01"
},
{
"GU" : "Person2",
"CW" : 2,
"Year" : 2015,
"_id" : "02"
},
{
"GU" : "Person1",
"CW" : 2,
"Year" : 2015,
"_id" : "03"
},
{
"GU" : "Person1",
"CW" : 3,
"Year" : 2015,
"_id" : "04"
},
{
"GU" : "Person1",
"CW" : 51,
"Year" : 2014,
"_id" : "05"
},
{
"GU" : "Person1",
"CW" : 51,
"Year" : 2014,
"_id" : "06"
}
Is there a way to merge the data based on CW and Year, counting the occurrences of each person for each week?
In summary, the desired output should be:
{Year: 2014, CW:51, GU:{Person1:2}},
{Year: 2015, CW:2, GU:{Person1:1, Person2:2}},
{Year: 2015, CW:3, GU:{Person1:1}}