0

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

2 Answers 2

1

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)
Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

df.reset_index(inplace=True)
df.rename(columns={df.columns[0]: 'BBID VALUE_DATE'}, inplace=True)
df.set_index('BBID VALUE_DATE' , inplace = True) 

3 Comments

you forgot to make the column as index again. One can do it like this df.set_index('BBID VALUE_DATE' , inplace = True)
Hmm so the BBID is the header for the column names and VALUE_DATE is the header for the row names. They are separate, sorry for being vague in the sc.
There is no such thing as "header for columns"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.