简体   繁体   中英

How to get rid of the index column name in a Pandas dataframe?

The column header used to be on the row index #2. When I converted the row to the header, number 2 is followed.

I haver tried reset_index and index.rename but they don't seem to get rid of number 2. Please help. Thanks!

2 Date Customer Product
3 10-Jan Tony Rubber
4 10-Jan Mary Paper
5 11-Jan Jane TV

You can use rename_axis() . The docs state that you can use the method to rename axis columns or indexes. For your program, use:

df.rename_axis(columns=None)

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