简体   繁体   中英

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?

熊猫

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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