-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Prevent OutOfBoundsDatetime error for constructing tz-aware series from list #54620
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
Conversation
5654f6e
to
9a54182
Compare
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
pandas/core/arrays/datetimes.py
Outdated
@@ -2182,7 +2182,8 @@ def _sequence_to_dt64ns( | |||
Returns | |||
------- | |||
result : numpy.ndarray | |||
The sequence converted to a numpy array with dtype ``datetime64[ns]``. | |||
The sequence converted to a numpy array with dtype ``datetime64[unit]``. | |||
Where `unit` is ns unless specified otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"specified otherwise" -> "specified otherwise by out_unit
"
@@ -1148,6 +1148,15 @@ def test_constructor_with_datetime_tz(self): | |||
result = DatetimeIndex(s, freq="infer") | |||
tm.assert_index_equal(result, dr) | |||
|
|||
def test_constructor_with_datetime_tz_ms(self): | |||
# explicit frequency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# GH#54620 explicit frequency
does this need a whatsnew for the bugfix? |
@AdrianDAlessandro can you address comments and merge main |
Yes, sorry I haven't been able to find time to continue working on this. I'm not convinced it's fully finished because the original bug is only for a timezone-aware series, which this fixes, but the bug also happens with the more generic case of all Datetime Series. This will require further changes to the Cython code in |
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
Done |
@@ -1148,6 +1148,15 @@ def test_constructor_with_datetime_tz(self): | |||
result = DatetimeIndex(s, freq="infer") | |||
tm.assert_index_equal(result, dr) | |||
|
|||
def test_constructor_with_datetime_tz_ms(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this will also fix .astype to non-nano. can you add a test for that
request for a test for .astype, otherwise LGTM |
@@ -27,7 +27,7 @@ | |||
PeriodArray, | |||
TimedeltaArray, | |||
) | |||
from pandas.core.arrays.datetimes import _sequence_to_dt64ns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we no longer test this function directly
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Note that this PR only fixes the case where the units are explicitly specified and it is a timezone-aware datetime. The more general case(s) appears to be more complicated.