Home > Back-end >  How to drop index column using panda while writing?
How to drop index column using panda while writing?

Time:10-28

df.columns = pd.MultiIndex.from_tuples(
    zip(['AA ', 'BB ', '','DD', 'EE',''],df.columns))

I used the above code in my script that's why I have to set index=True

df.to_excel(arg,index=True)

But now I want to drop my index column What can I Do?

I Tried : df.reset_index(inplace=True) data.reset_index(drop=True, inplace=True) df.drop() But no one is worked..!

CodePudding user response:

To drop the index column, use this:

df = df.reset_index(drop=True)

CodePudding user response:

Did you try setting index to 'False' while exporting to excel ?

df.to_excel(arg,index=False)
  • Related