There is a multi-index dataframe, with two indices, result_df:
print(result_df)
returns
a_column ... another_column
datetime_end_format datetime_end_format ...
1 2023 1159 ... 1027
2 2023 2765 ... 2466
3 2023 2493 ... 2303
4 2023 3016 ... 2860
5 2023 4174 ... 4036
6 2023 3916 ... 3870
7 2023 539 ... 542
Both indices are named "datetime_end_format":
print(result_df.index)
returns
MultiIndex([(1, 2023),
(2, 2023),
(3, 2023),
(4, 2023),
(5, 2023),
(6, 2023),
(7, 2023)],
names=['datetime_end_format', 'datetime_end_format'])
It is attempted to rename these:
result_df.index.rename(['month','year'])
However the index names are unchanged - running print(result_df.index) again shows no change.
What is the error in the code or the approach?