Amol_G
Amol_G

Reputation: 367

How to drop index column using panda while writing?

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..!

Upvotes: 1

Views: 62

Answers (2)

Ashutosh Yadav
Ashutosh Yadav

Reputation: 369

To drop the index column, use this:

df = df.reset_index(drop=True)

Upvotes: 1

Khaled DELLAL
Khaled DELLAL

Reputation: 921

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

df.to_excel(arg,index=False)

Upvotes: 0

Related Questions