我有以下数据框:
eff, par 0, par 1, par 2, par 3, par 4, par 5, par 6, par 7, par 8, par 9, par10, par11, par12, par13, par14
-0.133,0.989,0.554,5.524, NaN,0.000,0.702,0.500,-4.556,266.644,-1.635,5.764,1.351,0.561,0.013,775.924
-0.133,0.989,0.554,5.524, NaN,0.000,0.702,0.500,-4.556,266.644,-1.635,5.764,1.351,0.561,0.013,775.924
-0.133,0.989,0.554,5.524, NaN,0.000,0.702,0.500,-4.556,266.644,-1.635,5.764,1.351,0.561,0.013,775.924
您会注意到,数据框的标题中有很多空格,这在管理列中非常不切实际。因此,我想删除它们以便具有以下数据框:
eff,par 0,par 1,par 2,par 3,par 4,par 5,par 6,par 7,par 8,par 9,par10,par11,par12,par13,par14
-0.133,0.989,0.554,5.524, NaN,0.000,0.702,0.500,-4.556,266.644,-1.635,5.764,1.351,0.561,0.013,775.924
-0.133,0.989,0.554,5.524, NaN,0.000,0.702,0.500,-4.556,266.644,-1.635,5.764,1.351,0.561,0.013,775.924
-0.133,0.989,0.554,5.524, NaN,0.000,0.702,0.500,-4.556,266.644,-1.635,5.764,1.351,0.561,0.013,775.924
您知道一些简单易用的命令,还是我必须对标题进行循环并应用某种“条”。
感谢您的任何帮助 最好的
答案 0 :(得分:3)
您可以使用重命名:
df.rename(columns=lambda x: x.strip())