简体   繁体   English

如何重命名,熊猫中没有列名?

[英]How to rename, No column name in pandas?

I want to rename some columns but I am not getting these columns to rename.我想重命名一些列,但我没有让这些列重命名。 You can see in the image,I want to set the red tick value to index1 and for the green tick as index2 but I am not able to do because I am not getting these two columns for renaming?您可以在图像中看到,我想将红色刻度值设置为 index1,将绿色刻度设置为 index2,但我无法这样做,因为我没有得到这两列进行重命名?

熊猫

You are referrring to a multi-index dataframe, the green tick column is index.您指的是多索引数据框,绿色刻度列是索引。 You can use .reset_index() to get them as a column named "index" and later rename it, or use rename_axis(index=['red_ticks', 'green_ticks']) or whatever name you like.您可以使用.reset_index()将它们作为名为“index”的列然后重命名,或者使用rename_axis(index=['red_ticks', 'green_ticks'])或任何您喜欢的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM