Home » excel » python – how to prevent the index in a pandas dataframe from showing up in excel?

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

Posted by: admin May 14, 2020 Leave a comment

Questions:

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
How to&Answers:
df2.to_excel("filename", index=0)