Skip to content

DatetimeIndex and Timestamp have different implementation limits #24124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jbrockmendel opened this issue Dec 6, 2018 · 0 comments · Fixed by #39308
Closed

DatetimeIndex and Timestamp have different implementation limits #24124

jbrockmendel opened this issue Dec 6, 2018 · 0 comments · Fixed by #39308
Labels
Bug Datetime Datetime data dtype
Milestone

Comments

@jbrockmendel
Copy link
Member

Timestamp's minimum value is bounded away from np.iinfo(np.int64).min "to allow overflow free conversion with a microsecond resolution", but DatetimeIndex is not:

>>> dti = pd.date_range(end=pd.Timestamp.min, periods=2, freq='ns')
>>> dti
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pandas/core/base.py", line 77, in __repr__
    return str(self)
  File "pandas/core/base.py", line 57, in __str__
    return self.__bytes__()
  File "pandas/core/base.py", line 69, in __bytes__
    return self.__unicode__().encode(encoding, 'replace')
  File "pandas/core/indexes/base.py", line 927, in __unicode__
    data = self._format_data()
  File "pandas/core/indexes/base.py", line 970, in _format_data
    is_justify=is_justify, name=name)
  File "pandas/io/formats/printing.py", line 348, in format_object_summary
    first = formatter(obj[0])
  File "pandas/core/arrays/datetimelike.py", line 333, in __getitem__
    return self._box_func(val)
  File "pandas/core/arrays/datetimes.py", line 327, in <lambda>
    return lambda x: Timestamp(x, freq=self.freq, tz=self.tz)
  File "pandas/_libs/tslibs/timestamps.pyx", line 736, in pandas._libs.tslibs.timestamps.Timestamp.__new__
    ts = convert_to_tsobject(ts_input, tz, unit, 0, 0, nanosecond or 0)
  File "pandas/_libs/tslibs/conversion.pyx", line 324, in pandas._libs.tslibs.conversion.convert_to_tsobject
    check_dts_bounds(&obj.dts)
  File "pandas/_libs/tslibs/np_datetime.pyx", line 120, in pandas._libs.tslibs.np_datetime.check_dts_bounds
    raise OutOfBoundsDatetime(
pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 1677-09-21 00:12:43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants