1

this is the dtype of my dataframe:

tradePrice         first               float64
                   amax                float64
                   amin                float64
                   last                float64
                   <lambda>            float64
tradeVolume        <lambda>              int64
                   sum                   int64
                   mean                float64

I am trying to rename the name of the headers and I can not do this within the groupby. How can I rename it in the dataframe?

Giladbi
  • 1,822
  • 3
  • 19
  • 34

1 Answers1

1

You can use rename.

df = df.rename(columns={'amin':'new'}, level=1)

For rename lambdas use __name__ (check this solution with data):

f1 = lambda x: function1
f1.__name__ == 'custom_name1'

f2 = lambda x: function2
f2.__name__ == 'custom_name2'
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252