how to drop the title for data-frame columns

前端 未结 2 675
一向
一向 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
    
    0 讨论(0)
  • 2021-01-25 07:10

    These variables are represented through the name property:

    df.columns.name = None
    df.index.name = None
    
    0 讨论(0)
提交回复
热议问题