Skip to content
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

BUG: Series([big_timestamp], dtype=pd.DatetimeTZDtype("us", "US/Pacific")) raises #54442

Closed
Tracked by #5
jbrockmendel opened this issue Aug 6, 2023 · 3 comments
Closed
Tracked by #5
Assignees
Labels
Bug Datetime Datetime data dtype Non-Nano datetime64/timedelta64 with non-nanosecond resolution Series Series data structure

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Aug 6, 2023

ts = pd.Timestamp(2999, 1, 1)
ts2 = ts.tz_localize("US/Pacific")

dtype = pd.DatetimeTZDtype("us", "US/Pacific")

>>> ser = pd.Series([ts2], dtype=dtype)
[...]
pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: Cannot cast 2999-01-01 00:00:00-08:00 to unit='ns' without overflow.
@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 6, 2023
@lithomas1 lithomas1 added Datetime Datetime data dtype Series Series data structure Non-Nano datetime64/timedelta64 with non-nanosecond resolution and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 7, 2023
@AdrianDAlessandro
Copy link
Contributor

take

@AdrianDAlessandro
Copy link
Contributor

Further investigation reproduces this bug in multiple ways. It appears the underlying Cython code (in pandas._libs.tslib.pyx) still requires ns resolution. This is not limited to timezone-aware datetimes.

>>> pd.Series([pd.Timestamp(2999,1,1)], dtype="datetime64[us]")
[...]
pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: Cannot cast 2999-01-01 00:00:00 to unit='ns' without overflow., at position 0

Also if you don't specify the dtype for an out-of-bounds datetime then you just get an array with object dtype, and it doesn't infer it.

>>> pd.Series([pd.Timestamp(2000,1,1)])
0   2000-01-01
dtype: datetime64[ns]
>>> pd.Series([pd.Timestamp(2999,1,1)])
0    2999-01-01 00:00:00
dtype: object

@jbrockmendel
Copy link
Member Author

closed by #55768

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Non-Nano datetime64/timedelta64 with non-nanosecond resolution Series Series data structure
Projects
None yet
3 participants