When I try to get more than one aggregation for a DataFrame, I get a header with more than one row:
df = df.groupby(['user', 'cat1 'cat2'])
df = df.aggregate({
'user': ['count'],
'profit': [np.average, np.sum]
})
Output:
user profit
count average sum
user cat1 cat2
123 A 85963 1 91.33 56.22
456 A 5639 1 67.32 52.11
789 B 68593 1 33.55 45.88
Exporting this to csv results in two or more header rows:
,user,cat1,cat2,user,profit,profit
,,,,count,average,sum
[...]
What am I doing wrong?