When doing data processing in Python, the following error is reported:
pandas.errors.ParserError: Error tokenizing data. C error: Expected 3 fields in line 28, saw 4
The reason for the error
First, let’s take a look at error reporting:
pandas.errors.ParserError: Error tokenizing data. C error: Expected 3 fields in line 28, saw 4
Translation:
Alphaers. errors.parserror: Error marking data. C Error: Three fields are required on line 28, see 4
The error was caused by a data set format error.
The solution
We need to modify the data format or make some Settings in the read-in. The following two methods are feasible:
1. Modify the read-in code
Add the following parameters after reading the code:
error_bad_lines=False #Addition of parameters
2. Modify the file format
I made the error because I was lazy and modified the suffix name directly. The correct way to do this is to open the file in the format required by another existing dataset. For example, I need a CSV file, and the existing file is XLSX. I need to open another CSV file, and the suffix name cannot be directly modified.
Read More:
- Solution pandas.errors.ParserError : Error tokenizing data. C error: Buffer overflow caught
- ParserError: Error tokenizing data. C error: EOF inside string starting at row 917
- How to Fix Parser rerror: error tokenizing data. C error: expected 2 fields in line 53, saw 3
- Pandas read_ Error in json() valueerror: training data
- pandas parse_ Data exception, automatically skip
- The MySQL load data command parses and handles error 29 (errCode: 13) errors (in the Ubuntu environment)
- Python3-ValueError:not enough values to unpack (expected 2, got 0)
- error C2057: expected constant expression (Can the size of an array in C language be defined when the program is running?)
- Pandas multi column pandas.core.indexing . indexingerror: too many indexers error
- C # generate data in DataGridView into XML file
- Various errors (c + +)
- Three kinds of errors in C + + program
- C language error: expected declaration or statement at end of input
- C code compilation_ Error: expected expression before ‘Int’
- C# Compiler Errors
- Stm32f103c8t6 in keil compiler error: # 67: expected a “}” solution
- Oracle 12C installation process related errors and Solutions
- Python problem: indenta tionError:expected an Error resolution of indented block
- Python learning notes (5) — cross entropy error runtimeerror: 1D target tensor expected, multi target not supported