Changing index name in pandas dataframe
Question:
Answers:
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)
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)
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)
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)