Home > Enterprise >  Change the column name index with pandas
Change the column name index with pandas

Time:03-07

I have a df, and when I run df.columns, I get the result in the screenshot I am attaching. I do not understand what is the result in red referring to. Furthermore, I would like to have no "name".

screenshot

CodePudding user response:

Use rename_axis:

ri_2 = ri_2.rename_axis(None, axis=1)

CodePudding user response:

A simplified picture of what is df.columns is "it is a list of column names".

But it is only a simplified view. Actually it is an Index, something like a pandasonic Series, so it can have a name (as each Series).

One of possible options is to set it to None:

df.columns.name = None
  • Related