Pandas - remove the label of the column index

New answer for pandas 1.x, submitted by Ian Logie

df.columns.name = None

 

Old Answer from Oct 2018

Simply delete the name of the columns:

del df.columns.name

Also, note that df.index.names = [''] is not quite the same as del df.index.name.


Like this:

df = df.rename_axis(None)

This will get rid of everything on the top left. you can also do it in place: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.rename_axis.html


In Pandas 1.0.3 the following works:

df.columns.name = None

The 'accepted answer' above, del df.columns.name, leads to: 'AttributeError: can't delete attribute'