fix to_datetime default error suppression by cowpig · Pull Request #8894 · pandas-dev/pandas (original) (raw)
date format "%Y%m%d"
does not raise errors even when errors='raise'
and silently returns datetime.datetime
for out of bounds timestamp:
>>> pd.to_datetime('1300-01-01', format='%Y-%m-%d', errors='raise')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users//.virtual_envs/system/lib/python2.7/site-packages/pandas/tseries/tools.py", line 318, in to_datetime
return _convert_listlike(np.array([ arg ]), box, format)[0]
File "/Users//.virtual_envs/system/lib/python2.7/site-packages/pandas/tseries/tools.py", line 306, in _convert_listlike
raise e
pandas.tslib.OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 1300-01-01 00:00:00
>>> pd.to_datetime('13000101', format='%Y%m%d', errors='raise')
datetime.datetime(1300, 1, 1, 0, 0)