import pandas as pd
df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
print(df)
df1=df.rename(columns={"A": "a", "B": "c"})
print(df1)
结果:
A B
0 1 4
1 2 5
2 3 6
a c
0 1 4
1 2 5
2 3 6
进程已结束,退出代码为 0
import pandas as pd
df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
print(df)
df1=df.rename(columns={"A": "a", "B": "c"})
print(df1)
结果:
A B
0 1 4
1 2 5
2 3 6
a c
0 1 4
1 2 5
2 3 6
进程已结束,退出代码为 0