Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Changing index name in pandas dataframe

I have a dataframe that looks like this:
enter image description here

How can I change the Unnamed: 0 and the blank header of columns so it would look like this:
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You want to change both the names of index and columns axis.

You can do it like this:

df.index.name = 'BBID'
df.columns.name = 'VALUE_DATE'

or with a chained method like this:

df = df.rename_axis('VALUE_DATE').rename_axis('BBID', axis=1)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading