从 pandas 导出到没有行名(索引)的Excel? [英] Export from pandas to_excel without row names (index)?
问题描述
我正在尝试将熊猫中的数据框打印到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屋!