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

DEPS: Make pytz an optional dependency #59089

Merged
merged 28 commits into from
Aug 12, 2024

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
@@ -45,7 +38,7 @@ from pandas._libs.tslibs.util cimport (

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
47 checks passed
@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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: Default to stdlib timezone objects instead of pytz
2 participants