Панды переименования индекса
df.index = df.index.rename('new_index_name')
# Source: https://pandas.pydata.org/docs/reference/api/pandas.Index.rename.html
D Goglia
df.index = df.index.rename('new_index_name')
# Source: https://pandas.pydata.org/docs/reference/api/pandas.Index.rename.html
df.rename(index={'alpha': 'mu'})
df_new = df.rename(columns={'A': 'a'}, index={'ONE': 'one'})
print(df_new)
# a B C
# one 11 12 13
# TWO 21 22 23
# THREE 31 32 33
print(df)
# A B C
# ONE 11 12 13
# TWO 21 22 23
# THREE 31 32 33
df.rename(index={'Republic of Korea':'South Korea'},inplace=True)
df1.rename(index={0: 'a', 1:'b'})
# For index name:
df.index = df.index.rename('new_name')
# or
df.index.rename('new_name', inplace=True)
# For column name:
df.columns = df.columns.rename('new_name')
# or
df.columns.rename('new_name', inplace=True)