-1

Using this code to name the first column in the dataframe: df1 = df1.rename(columns={'Unnamed:0' : 'time'}, inplace=True) This gives me NoneType object.

I tried removing inplace=True but then it just gives back the dataframe just like the original. No update in column name.

aynber
  • 22,380
  • 8
  • 50
  • 63
Ankita
  • 5
  • 2
  • It still doesn't update the column name. – Ankita Jun 29 '21 at 11:24
  • For the first column, yes! ```df1.columns Out[75]: Index(['Unnamed: 0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'], dtype='object')``` – Ankita Jun 29 '21 at 11:45

1 Answers1

0

You should be doing,

df1 = df1.rename(columns={'Unnamed: 0' : 'time'}, inplace=False)

or

df1.rename(columns={'Unnamed: 0' : 'time'}, inplace=True)

Note the column name is Unnamed: 0 (note the space)

Sreeram TP
  • 11,346
  • 7
  • 54
  • 108