renaming column headings python pandas code example
Example 1: renaming headers pandasd
df = df.rename(columns={"old_col1": "new_col1", "old_col2": "new_col2"})
Example 2: renaming column in dataframe pandas
df.rename({'a': 'X', 'b': 'Y'}, axis=1, inplace=True)
df
X Y c d e
0 x x x x x
1 x x x x x
2 x x x x x