1import pandas as pd
2data = pd.read_csv(file)
3data.rename(columns={'original':'new_name'}, inplace=True)
1df.rename(columns={"old_col1": "new_col1", "old_col2": "new_col2"}, inplace=True)
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 = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
2
3# Option 1
4df.rename({"A": "a", "B": "c"}, axis=1)
5
6# Option 2
7df.rename(columns={"A": "a", "B": "c"})
8
9# Result
10 a c
110 1 4
121 2 5
132 3 6