When processing raw data, the following error occurs:
id,name,date
0,a,2020/01/01
0,b,2020/01/01
0,c,2020/01/01
0,d,2020/01/01
0,e,2020/01/01
0,f,9999/01/01
It was treated with panda
:
data = pandas.read_csv(file, sep=";", encoding="ISO-8859-1", parse_dates=["date"], date_parser=lambda x: pandas.to_datetime(x, format="%d.%m.%Y"))
But the running time is wrong, which means out of bonds timestamp
.
Our current approach is to skip the exception line,
The following line needs to be added
date_parser=lambda x: pd.to_datetime(x, errors="coerce")
There are three kinds of assignments for the errors parameter. The default value is’ raise ‘. An error will be reported if the parsing does not conform to the specification.
You can assign the errors parameter to “coerce” and set the time format of the error to NAT during parsing. If you don’t want to deal with the wrong time format, you can assign errors to ‘ignore’, so that the original format is the same.
errors{‘ignore’, ‘raise’, ‘coerce’}, default ‘raise’
If ‘raise’, then invalid parsing will raise an exception.If ‘coerce’, then invalid parsing will be set as NaT.If ‘ignore’, then invalid parsing will return the input.
Read More:
- Pandas read_ Error in json() valueerror: training data
- circuit_breaking_exception,“reason“:“[parent] Data too large, data for [<http_request>]
- Python error: pandas.errors.ParserError: Error tokenizing data. C error: Expected 3……
- Jetson nano uses Python to read and parse GPS data (GPRMC, gpgga).
- Solution pandas.errors.ParserError : Error tokenizing data. C error: Buffer overflow caught
- Mybatis openSession.commit () manually submit data and openSession.commit (true) automatically submit data
- A solution to automatically convert special characters into Unicode when taking out data from MySQL and encapsulating it into JSON
- Pandas multi column pandas.core.indexing . indexingerror: too many indexers error
- Maven skip unit test- maven.test.skip And skipstests
- MySQL operation and maintenance slave_ skip_ errors
- SSIS Exception: Failed to retrieve long data for column “TS_Description”
- Maven skip unit test
- MySQL skip grant tables add user error 1290
- Inconsistency between adapter data and UI data after dragging recyclerview (data disorder)
- Pandas memory error
- Converting string object into datetime type in pandas
- Pandas generates new columns through LOC
- Multithreading: when doing unit test, use thread pool to find that the specified code is not running and skip directly
- Problem solving: Pandas: keyerror: [ ] not in index
- Data analysis to obtain Yahoo stock data: some problems are encountered when using panda datareader (cannot import name ‘is_ list_ Like ‘problem)