Skip to content

Conversation

@AdrianDAlessandro
Copy link
Contributor

@AdrianDAlessandro AdrianDAlessandro commented Aug 18, 2023

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.

@AdrianDAlessandro
Copy link
Contributor Author

@mroeschke mroeschke requested a review from jbrockmendel August 18, 2023 17:05
@mroeschke mroeschke added Timezones Timezone data dtype Non-Nano datetime64/timedelta64 with non-nanosecond resolution labels Aug 18, 2023
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Sep 21, 2023
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.
Copy link
Member

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"

tm.assert_index_equal(result, dr)

def test_constructor_with_datetime_tz_ms(self):
# explicit frequency
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# GH#54620 explicit frequency

@jbrockmendel
Copy link
Member

does this need a whatsnew for the bugfix?

@jbrockmendel
Copy link
Member

@AdrianDAlessandro can you address comments and merge main

@AdrianDAlessandro
Copy link
Contributor Author

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 tslib.pyx, specifically the array_to_datetime function. But I've never really worked with Python outside of this PR.

@mroeschke
Copy link
Member

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.

@mroeschke mroeschke closed this Oct 22, 2023
@AdrianDAlessandro
Copy link
Contributor Author

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

@mroeschke mroeschke reopened this Oct 23, 2023
result = DatetimeIndex(s, freq="infer")
tm.assert_index_equal(result, dr)

def test_constructor_with_datetime_tz_ms(self):
Copy link
Member

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

@jbrockmendel
Copy link
Member

request for a test for .astype, otherwise LGTM

PeriodArray,
TimedeltaArray,
)
from pandas.core.arrays.datetimes import _sequence_to_dt64ns
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Non-Nano datetime64/timedelta64 with non-nanosecond resolution Stale Timezones Timezone data dtype

3 participants