I'm trying to summarize and grouping multiple dictionary into single dictionary in array based on the dictionary's value. Also, get the count of the grouping value.
For example in the raw input format of 'sms', i intend to group by subscribe_name ,endpoint ,errorId and get its count.
I have no much idea where to start and hope some guidelines from here and library resource can be utilised.
Desired payload format:
{
"myDeviceX": {
"channel": {
"sms": [
{
"endpoint": "+123456789",
"errorId": ["1","2","3","4"],
"error_num": 4,
"subscriber_name": "tester1"
},
{
"endpoint": "+234567890",
"errorId": ["1"],
"error_num": 1,
"subscriber_name": "tester2"
}
],
"email": [
{
"endpoint": "[email protected]",
"errorId": ["1","2","3"],
"error_num": 3,
"subscriber_name": "tester1"
}
]
}
}
}
Raw input payload format:
{
"myDeviceX": {
"sms": [
{
"endpoint": "+123456789",
"errorId": "1",
"subscriber_name": "tester1"
},
{
"endpoint": "+123456789",
"errorId": "2",
"subscriber_name": "tester1"
},
{
"endpoint": "+123456789",
"errorId": "3",
"subscriber_name": "tester1"
},
{
"endpoint": "+123456789",
"errorId": "4",
"subscriber_name": "tester1"
},
{
"endpoint": "+234567890",
"errorId": "1",
"subscriber_name": "tester2"
}
],
"email": [
{
"endpoint": "[email protected]",
"errorId": "1",
"subscriber_name": "tester1"
},
{
"endpoint": "[email protected]",
"errorId": "2",
"subscriber_name": "tester1"
},
{
"endpoint": "[email protected]",
"errorId": "3",
"subscriber_name": "tester1"
}
]
}
}
pandas, but you'll probably have to slightly restructure your data to make it work as a dataframe