Suppose I have the following:
In [20]: df.groupby("dummy").agg({"returns": [np.mean, np.sum]})
Out[20]:
returns
sum mean
dummy
1 0.285833 0.028583
How do I remove the "returns" header? So that I have a dataframe with columns 'sum' and 'mean'?
Use -
df.columns = df.columns.droplevel(0)
To drop the top column level
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With