3

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
yoshiserry
  • 20,175
  • 35
  • 77
  • 104
  • 1
    possible duplicate of [Python to\_excel without row names (index)?](http://stackoverflow.com/questions/22089317/python-to-excel-without-row-names-index) – EdChum Mar 08 '14 at 21:24

1 Answers1

7
df2.to_excel("filename", index=0)
Amit
  • 19,780
  • 6
  • 46
  • 54
  • syntax is the first line on the help page, by default `index=True` is passed. If you explicitly pass it as False then you should not see the index in the output file. – Amit Mar 08 '14 at 12:47
  • @yoshiserry you should accept the answer if it worked for you. – saladi Nov 08 '15 at 00:47