python修改列名的几种方法

参考链接:https://blog.csdn.net/littleRpl/article/details/100117428

三 str 批量修改列名
将列名’a1’, ‘b1’… 批量改为’a2’, 'b2’…

df.columns = df.columns.str.replace('1', '2')
df
   a2  b2  c2  d2
0   0   1   2   3
1   4   5   6   7
2   8   9  10  11
3  12  13  14  15
4  16  17  18  19

你可能感兴趣的:(#,pandas,1024程序员节)