I'm trying to manipulate data, and I'd need a solution for this
Tried mapping in different ways, but none of them worked.
This is the input data:
data_input = {
2000: [{
_id: 0,
name: "Jeff",
value: 130,
year: 2000
},
{
_id: 1,
name: "Bill",
value: 30,
year: 2000
}
],
2001: [{
_id: 0,
name: "Jeff",
value: 20,
year: 2001
},
{
_id: 1,
name: "Bill",
value: 100,
year: 2001
}
]
}
Here is the expected result:
data_output = [{
year: 2000,
year_data: [{
_id: 0,
name: "Jeff",
value: 130
},
{
_id: 1,
name: "Bill",
value: 30
}
]
},
{
year: 2001,
year_data: [{
_id: 0,
name: "Jeff",
value: 20
},
{
_id: 1,
name: "Bill",
value: 100
}
]
}
]