数据如下:
>>>import pandas as pd
>>>a = pd.DataFrame({'A':[1,2,3], 'B':[4,5,6], 'C':[7,8,9]})
>>> a
A B C
0 1 4 7
1 2 5 8
2 3 6 9
>>>a.columns = ['a','b','c']
>>>a
a b c
0 1 4 7
1 2 5 8
2 3 6 9
但是缺点是必须写三个,要不报错。
>>>a.rename(columns={'A':'a', 'B':'b', 'C':'c'}, inplace = True)
>>>a
a b c
0 1 4 7
1 2 5 8
2 3 6 9