-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
Milestone
Description
Hi,
I have a situation where I have "far away" end dates (3 examples included below). Normal Python strptime conversion handles this correctly, but the to_datetime functionality does a Martin McFly and ends up in the 1800s. See this example that reproduces it:
# input
time_ser = pd.Series([np.nan, '2013-04-08 00:00:00.000', '2013-06-04 00:00:00.000', '2013-09-06 00:00:00.000', '2013-10-02 00:00:00.000', '2013-10-03 00:00:00.000', '2013-10-30 00:00:00.000', '2013-10-31 00:00:00.000', '2013-11-30 00:00:00.000', '2013-12-02 00:00:00.000', '2013-12-17 00:00:00.000', '2013-12-31 00:00:00.000', '2014-01-15 00:00:00.000', '2014-01-31 00:00:00.000', '2014-02-15 00:00:00.000', '2014-02-28 00:00:00.000', '2014-03-15 00:00:00.000', '2014-03-31 00:00:00.000', '2014-06-15 00:00:00.000', '2014-06-30 00:00:00.000', '2099-12-31 00:00:00.000', '2999-12-31 00:00:00.000', '9990-12-31 00:00:00.000', '9999-12-31 00:00:00.000'])
# see last 3 results
pd.to_datetime(time_ser, '%Y-%m-%d %H:%M:%S.%f')
# normal python
import math
for x in sorted(time_ser.unique()):
if isinstance(x, basestring):
print '{} converts to {}'.format( x, datetime.datetime.strptime(x, '%Y-%m-%d %H:%M:%S.%f'))
# This is the erroneous result:
21 1830-11-22 00:50:52.580896768
22 1807-03-30 05:56:08.066277376
23 1816-03-29 05:56:08.066277376
I'm running Pandas 0.12 on Ubuntu 12.04LTS with Python 2.7.3. I could not find this issue registered yet.
Kind regards,
Carst