Python Pandas 错误标记数据 [英] Python Pandas Error tokenizing data
本文介绍了Python Pandas 错误标记数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 Pandas 来操作 .csv 文件,但我收到此错误:
I'm trying to use pandas to manipulate a .csv file but I get this error:
pandas.parser.CParserError:标记数据时出错.C 错误:第 3 行应为 2 个字段,看到 12
pandas.parser.CParserError: Error tokenizing data. C error: Expected 2 fields in line 3, saw 12
我曾尝试阅读 Pandas 文档,但一无所获.
I have tried to read the pandas docs, but found nothing.
我的代码很简单:
path = 'GOOG Key Ratios.csv'
#print(open(path).read())
data = pd.read_csv(path)
我该如何解决这个问题?我应该使用 csv
模块还是其他语言?
How can I resolve this? Should I use the csv
module or another language ?
文件来自Morningstar一个>
推荐答案
你也可以试试;
data = pd.read_csv('file1.csv', error_bad_lines=False)
请注意,这会导致跳过违规行.
Do note that this will cause the offending lines to be skipped.
这篇关于Python Pandas 错误标记数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文