1>>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
2>>> df.rename(columns={"A": "a", "B": "c"})
3 a c
40 1 4
51 2 5
62 3 6
7
1df.rename(columns={"A": "a", "B": "b", "C": "c"},
2errors="raise", inplace=True)
3
1#df.rename() will only return a new df with the new headers
2#df = df.rename() will change the heders of the current dataframe
3df = df.rename(columns={"old_col1": "new_col1", "old_col2": "new_col2"})
1print(df.rename(columns={'A': 'a', 'C': 'c'}))
2# a B c
3# ONE 11 12 13
4# TWO 21 22 23
5# THREE 31 32 33
6