赞
踩
本文转自知乎博文Zhuang Tommy Pandas 3:如何修改columns的名称 - 知乎 (zhihu.com)
@Zhuang Tommy
- col_names = ["City","Colors_Reported","Shape_Reported","State","Time"]
-
- ufo = pd.read_csv(r"ufo.csv", header = 0, names = col_names)
- col_names = ["City","Colors_Reported","Shape_Reported","State","Time"]
-
- ufo = pd.read_csv(r"ufo.csv")
-
- ufo.columns = col_names
- ufo = pd.read_csv(r"ufo.csv")
-
- ufo.rename(columns = {"Colors Reported" : "Colors_Reported",
-
- "Shape Reported" : "Shape_Reported"}, inplace = True)
- ufo = pd.read_csv(r"ufo.csv")
-
- ufo.columns = ufo.columns.str.replace(" ","_")
关于更详细的pandas DataFrame教程,可参考@Ding Jiaxiong 的博文
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。