如何避免 Python/Pandas 在保存的 csv 中创建索引? [英] How to avoid Python/Pandas creating an index in a saved csv?
本文介绍了如何避免 Python/Pandas 在保存的 csv 中创建索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在对文件进行一些编辑后,我试图将 csv 保存到文件夹中.
I am trying to save a csv to a folder after making some edits to the file.
每次我使用 pd.to_csv('C:/Path of file.csv')
时,csv 文件都有一个单独的索引列.我想避免将索引打印到 csv.
Every time I use pd.to_csv('C:/Path of file.csv')
the csv file has a separate column of indexes. I want to avoid printing the index to csv.
我试过:
pd.read_csv('C:/Path to file to edit.csv', index_col = False)
并保存文件...
pd.to_csv('C:/Path to save edited file.csv', index_col = False)
但是,我仍然得到了不需要的索引列.保存文件时如何避免这种情况?
However, I still got the unwanted index column. How can I avoid this when I save my files?
推荐答案
使用index=False
.
df.to_csv('your.csv', index=False)
这篇关于如何避免 Python/Pandas 在保存的 csv 中创建索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文