Export from pandas to_excel without row names (index)?

ghz 1years ago ⋅ 1642 views

Question

I'm trying to print out a dataframe from pandas into Excel. Here I am using to_excel() functions. However, I found that the 1st column in Excel is the "index",

0   6/6/2021 0:00   8/6/2021 0:00
1   4/10/2024 0:00  6/10/2024 0:00
2   4/14/2024 0:00  6/14/2024 0:00

Is there any ways to get rid of the first column?


Answer

You need to set index=False in to_excel in order for it to not write the index column out, this semantic is followed in other Pandas IO tools, see <http://pandas.pydata.org/pandas- docs/stable/generated/pandas.DataFrame.to_excel.html> and http://pandas.pydata.org/pandas-docs/stable/io.html