I am facing a data manipulation challenge and seeking a solution.
I have attempted various mapping methods, but none have been successful.
Below is the input dataset:
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
}
]
}
The desired outcome should be as follows:
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
}
]
}
]