I’m trying to rename the unnamed index of a dataframe I’ve called “no_labels” using:
no_labels.rename(index={'Unnamed: 0':'new column name'}, inplace=True)
This produces no error, but does nothing, and the first column is in fact the (base) index, and remains unnamed. Am I doing something wrong? I did some reading and found that I could use:
no_labels.index.name = 'COUNTRY_CODE'
and found success. I am guessing this is because the index of the Pandas dataframe is a series? Thanks very much for any help or corrections!
screenshot of failed code: