成功解决ParserError: Error tokenizing data. C error: Expected 2 fields in line 53, saw 3

简介: 成功解决ParserError: Error tokenizing data. C error: Expected 2 fields in line 53, saw 3


目录

解决问题

解决思路

解决方法


 

 

解决问题

File "pandas\_libs\parsers.pyx", line 2021, in pandas._libs.parsers.raise_parser_error

pandas.errors.ParserError: Error tokenizing data. C error: Expected 2 fields in line 53, saw 3

 

 

解决思路

pandas.errors.ParserError:解析错误:标记数据的错误。C错误:在第53行中预期有2个字段,见3

 

 

解决方法

因为读取的是csv文件,分隔默认采用的是逗号,分析可知,读取的数据中某个格内包含两个字段,即值内可能包含两个逗号。

指定参数,error_bad_lines=False

data= pd.read_csv(data_file, error_bad_lines=False)


相关文章
|
5月前
|
JSON Java 数据格式
JSON parse error: Unexpected character (‘t‘ (code 116)): was expecting double-quote to start field n
JSON parse error: Unexpected character (‘t‘ (code 116)): was expecting double-quote to start field n
|
7月前
|
索引
Elasticsearch exception [type=illegal_argument_exception, reason=index [.1] is the write index for data stream [slowlog] and cannot be deleted]
在 Elasticsearch 中,你尝试删除的索引是一个数据流(data stream)的一部分,而且是数据流的写入索引(write index),因此无法直接删除它。为了解决这个问题,你可以按照以下步骤进行操作:
492 0
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
131 0
|
7月前
|
Perl
报错:error Parsing error: x-invalid-end-tag
报错:error Parsing error: x-invalid-end-tag
159 0
error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
146 0
成功解决absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'data_format'
成功解决absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'data_format'
报错:pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 7, saw 2
报错:pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 7, saw 2
报错:pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 7, saw 2