Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Out of bounds nanosecond timestamp

I have a variable ['date_hiring'] in Googlespeedsheet in format like

16.01.2016

I import it in Python, the variable has an object type. I try to convert to datetime

from datetime import datetime
data['date_hiring'] = pd.to_datetime(data['date_hiring'])

and i get

OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 16-01-06 00:00:00

i know from this pandas out of bounds nanosecond timestamp after offset rollforward plus adding a month offset that

Since pandas represents timestamps in nanosecond resolution, the timespan that can be represented using a 64-bit integer is limited to approximately 584 years

but in original data in the Googlespeedsheet i have no data like '16.01.06'

Just like '16.06.2006'

So the problem is in converting

How to improve it?

like image 986
Edward Avatar asked Oct 06 '16 21:10

Edward


1 Answers

According to the documentation, the dayfirst field defaults to false:

dayfirst : boolean, default False

So it must have decided that there was a malformed date there and tried to interpret it as a time-of-day.

But even then it probably didn't think that 16 point anything could be hours or minutes, so it tried to convert it as seconds. But there is a extra decimal point so it gave up and said I don't like the fractional seconds. (Or something like that.)

I think you can fix it by giving an explicit format string or at least setting dayfirst.

like image 144
wallyk Avatar answered Nov 03 '22 11:11

wallyk