如何避免Python / Pandas在保存的csv中创建索引? [英] How to avoid Python/Pandas creating an index in a saved csv?

查看:1042
本文介绍了如何避免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。

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

pd.to_csv('your.csv', index=False)

这篇关于如何避免Python / Pandas在保存的csv中创建索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆