Skip to content

Conversation

@mroeschke
Copy link
Member

This makes pandas return zoneinfo.ZoneInfo objects by default from string inputs

@mroeschke mroeschke added Timezones Timezone data dtype Dependencies Required and optional dependencies labels Jun 25, 2024
@mroeschke mroeschke requested a review from MarcoGorelli as a code owner June 25, 2024 00:41
@mroeschke mroeschke modified the milestone: 3.0 Jun 25, 2024
cdef int64_t NPY_NAT = get_nat()
cdef tzinfo utc_stdlib = timezone.utc
cdef tzinfo utc_pytz = pytz.utc
cdef object utc_pytz = pytz.UTC if pytz else None
Copy link
Member

Choose a reason for hiding this comment

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

cant we keep this as a tzinfo object?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I had thought cython wouldn't like tzinfo since this could be None, but was able to keep as tzinfo

if ZoneInfo is None:
return False
return isinstance(tz, ZoneInfo)
return isinstance(tz, zoneinfo.ZoneInfo)
Copy link
Member

Choose a reason for hiding this comment

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

might be a small bump by doing cdef type ZoneInfo at the module level?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure thing. Added

@mroeschke
Copy link
Member Author

Will merge at the end of the week if there are no further comments

@mroeschke mroeschke merged commit 96d732e into pandas-dev:main Aug 12, 2024
@mroeschke mroeschke deleted the deps/pytz/optional branch August 12, 2024 20:06
shreyas-dev pushed a commit to shreyas-dev/pandas that referenced this pull request Aug 13, 2024
* Make pytz an optional dependency * Start to address tests * Fix tests * Fix tests * Fix test, import optional pytz in conftest * Fix formatting * Change minimum * remove type ignore * another pa under 17 * Address comments * Undo file * Fix pyarrow 17 test * Test xpasses on pyarrow 18
ts = pd.Timestamp(2024, 1, 1).tz_localize("US/Pacific")
ts.tz
``pytz`` timezone objects are still supported when passed directly, but they will no longer be returned by default
Copy link

Choose a reason for hiding this comment

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

pytz timezone objects are still supported when passed directly, but they will no longer be returned by default

This is a bit confusing. It suggests, that pd.Timestamp and others can be used to make it do return pytz objects.

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

Labels

Dependencies Required and optional dependencies Timezones Timezone data dtype

3 participants