yoshiserry
yoshiserry

Reputation: 21395

how to prevent the index in a pandas dataframe from showing up in excel?

I have a pandas dataframe (df) which contains some data I would like to output to excel, however I do not want the default index, or any index for that matter being printed to the worksheet.

Is it df.values?

df2 
1  |category| num 
2  |A       | 1
3  |A       | 2
4  |B       | 3

I want to print to worksheet just:

df2 
|category| num 
|A       | 1
|A       | 2
|B       | 3

Upvotes: 3

Views: 9857

Answers (1)

Amit
Amit

Reputation: 20516

df2.to_excel("filename", index=0)

Upvotes: 7

Related Questions