python – 如何在没有带有pandas的“未命名”行的情况下读取csv文件?
发布时间:2020-11-18 05:32:41 所属栏目:Python 来源:互联网
导读:参见英文答案 Pandas: how to get rid of `Unnamed:` column in a dataframe2个 我正在写一个.csv文件: my_data_frame.to_cav(some_path) 尝试使用以下内容读取文件时: pd.read_csv(some_path) 我可以说,添
|
参见英文答案 >
Pandas: how to get rid of `Unnamed:` column in a dataframe2个
my_data_frame.to_cav("some_path")
尝试使用以下内容读取文件时: pd.read_csv("some_path")
我可以说,添加了一个未命名的列. 解决方法to_csv()在默认情况下写入索引,因此您可以在保存CSV时禁用索引:df.to_csv('file.csv',index=False)
或者在阅读时指定索引列: df = pd.read_csv('file.csv',index_col=0) (编辑:日照站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 【Python】各类距离公式
- python – matplotlib.pyplot.imshow:在使用属性“sharex”
- python proxy-auth中的phantomjs selenium无法正常工作
- python – 在rdflib中使用上下文
- 在Python中处理不同类型的规范方法是什么?
- python – 如何避免使用Google App Engine发送电子邮件时出
- python – 从py2exe’d程序连接到Oracle时出错:无法获取Or
- [Python] 使用dict和set
- django – Travis:“创建测试数据库时出错:创建数据库的权
- python – ‘AnonymousUser’对象没有属性’后端’
