how to drop the title for data-frame columns

前端 未结 2 698
一向
一向 2021-01-25 06:52

I come up with a dataframe like this, I wonder how can we change or drop the \'id\' and \'date\' as they are just the names for index and columns.

id                 


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-25 07:00

    Option 1
    rename_axis

    df.rename_axis(None, 1, inplace=True)  # 1 is for axis=1
    

    Option 2
    reassign df.columns

    df.columns = df.columns.tolist()
    

    Option 3
    Setting the name attribute, as described by Boud.

    df.columns.name = None
    df.index.name = None
    

提交回复
热议问题