1# Basic syntax:
2# Assign column names to a Pandas dataframe:
3pandas_dataframe.columns = ['list', 'of', 'column', 'names']
4# Note, the list of column names must equal the number of columns in the
5# dataframe and order matters
6
7# Rename specific column names of a Pandas dataframe:
8pandas_dataframe.rename(columns={'column_name_to_change':'new_name'})
9# Note, with this approach, you can specify just the names you want to
10# change and the order doesn't matter
11
12# For rows, use "index". E.g.:
13pandas_dataframe.index = ['list', 'of', 'row', 'names']
14pandas_dataframe.rename(index={'row_name_to_change':'new_name'})
1df_new = df.rename(columns={'A': 'a'}, index={'ONE': 'one'})
2print(df_new)
3# a B C
4# one 11 12 13
5# TWO 21 22 23
6# THREE 31 32 33
7
8print(df)
9# A B C
10# ONE 11 12 13
11# TWO 21 22 23
12# THREE 31 32 33
13