Remove index name in pandas Remove index name in pandas pandas pandas

Remove index name in pandas


Alternatively you can just assign None to the index.name attribute:

>>> df.index.name = None>>> print(df)         Column 1    Apples          1Oranges         2Puppies         3Ducks           4


Use del df.index.name

In [16]: dfOut[16]:         Column 1fooApples          1Oranges         2Puppies         3Ducks           4In [17]: del df.index.nameIn [18]: dfOut[18]:         Column 1Apples          1Oranges         2Puppies         3Ducks           4


From version 0.18.0 you can use rename_axis:

print df         Column 1foo              Apples          1Oranges         2Puppies         3Ducks           4print df.index.namefooprint df.rename_axis(None)         Column 1Apples          1Oranges         2Puppies         3Ducks           4print df.rename_axis(None).index.nameNone# To modify the DataFrame itself:df.rename_axis(None, inplace=True)print df.index.nameNone