I have a pandas dataFrame.After printing the pandas DataFrame the results looks like below
country branch no_of_employee total_salary count_DOB count_email
x a 30 2500000 20 25
x b 20 350000 15 20
y c 30 4500000 30 30
z d 40 5500000 40 40
z e 10 1000000 10 10
z f 15 1500000 15 15
i would like to convert this into user defined user format like
{
"x": [
{
"Branch": "a",
"no_employee": 30
},
{
"Branch": "b",
"no_employee": 20
}
],
"y": [
{
"Branch": "c",
"no_employee": 30
},
{
"Branch": "d",
"no_employee": 40
}
],
"z": [
{
"Branch": "d",
"no_employee": 40
},
{
"Branch": "e",
"no_employee": 10
},
{
"Branch": "f",
"no_employee": 15
}
]
}
How can i convert this dataFrame to this format