I have this current column name:
print(common_nodes_df.columns[0])
('0', '1')
but when I try to change it to:
common_nodes_df.columns[0] = 1
I get this error:
Index does not support mutable operations
What could I do to get around this?
CodePudding user response:
You must replace the whole column names. In your case,
df.columns = [1] list(df.columns[1:])
CodePudding user response:
df.rename({'1': 1}, axis=1, inplace=True)
CodePudding user response:
- use replace OR
- while changing the name use inplace = True