没有行名(索引)从 pandas 导出到_excel? [英] Export from pandas to_excel without row names (index)?
问题描述
我正在尝试将 Pandas 中的数据框打印到 Excel 中.这里我使用的是 to_excel() 函数.但是,我发现Excel中的第一列是索引",
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?
推荐答案
to_excel
需要设置index=False
才能不写入索引列出来,这个语义在其他 Pandas IO 工具中被遵循,参见 http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_excel.html 和 http://pandas.pydata.org/pandas-docs/stable/io.html
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
这篇关于没有行名(索引)从 pandas 导出到_excel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!