REGR? no error anymore when converting out of bounds datetime64[non-ns] data · Issue #26206 · pandas-dev/pandas (original) (raw)
In [1]: pd.Series(np.array(['2262-04-12'], dtype='datetime64[D]'))
Out[1]:
0 1677-09-21 00:25:26.290448384
dtype: datetime64[ns]
In [1]: pd.Series(np.array(['2262-04-12'], dtype='datetime64[D]'))
---------------------------------------------------------------------------
OutOfBoundsDatetime Traceback (most recent call last)
<ipython-input-1-b3f7cbbf1054> in <module>()
----> 1 pd.Series(np.array(['2262-04-12'], dtype='datetime64[D]'))
~/miniconda3/envs/pandas022/lib/python3.6/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath)
264 raise_cast_failure=True)
265
--> 266 data = SingleBlockManager(data, index, fastpath=True)
267
268 generic.NDFrame.__init__(self, data, fastpath=True)
~/miniconda3/envs/pandas022/lib/python3.6/site-packages/pandas/core/internals.py in __init__(self, block, axis, do_integrity_check, fastpath)
4400 if not isinstance(block, Block):
4401 block = make_block(block, placement=slice(0, len(axis)), ndim=1,
-> 4402 fastpath=True)
4403
4404 self.blocks = [block]
~/miniconda3/envs/pandas022/lib/python3.6/site-packages/pandas/core/internals.py in make_block(values, placement, klass, ndim, dtype, fastpath)
2955 placement=placement, dtype=dtype)
2956
-> 2957 return klass(values, ndim=ndim, fastpath=fastpath, placement=placement)
2958
2959 # TODO: flexible with index=None and/or items=None
~/miniconda3/envs/pandas022/lib/python3.6/site-packages/pandas/core/internals.py in __init__(self, values, placement, fastpath, **kwargs)
2468 def __init__(self, values, placement, fastpath=False, **kwargs):
2469 if values.dtype != _NS_DTYPE:
-> 2470 values = tslib.cast_to_nanoseconds(values)
2471
2472 super(DatetimeBlock, self).__init__(values, fastpath=True,
pandas/_libs/tslib.pyx in pandas._libs.tslib.cast_to_nanoseconds()
pandas/_libs/tslib.pyx in pandas._libs.tslib._check_dts_bounds()
OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 2262-04-12 00:00:00
In [2]: pd.__version__
Out[2]: '0.22.0'
cc @jbrockmendel any idea if this was changed on purpose or to what refactoring could have been the cause of this change?