I have a data like this,
dayname A B C D E
0 Friday 136.0 239.0 0.0 0.0 283.0
1 Monday 305.0 431.0 0.0 0.0 845.0
2 Saturday 0.0 3.0 0.0 0.0 11.0
I want OP :
{
'Friday' :[136, 239, 0, 283],
'Monday' :[305, 431, 0, 845],
'Saturday' :[0, 3, 0, 11]
}
Here is code I have tried,
output = (pd.DataFrame(df).groupby(['dayname','areaName'])['avgCount'].sum().unstack(fill_value=0).rename_axis(None, 1).reset_index())
print(output)
ot = pd.DataFrame(output)
#ot contains the above mentioned data
How to achieve this?