[SPARK-54937][PYTHON][TESTS][FOLLOW-UP] Fix pytz-specific tz assertion for pandas 3 zoneinfo#57071
Closed
fangchenli wants to merge 1 commit into
Closed
[SPARK-54937][PYTHON][TESTS][FOLLOW-UP] Fix pytz-specific tz assertion for pandas 3 zoneinfo#57071fangchenli wants to merge 1 commit into
fangchenli wants to merge 1 commit into
Conversation
…n for pandas 3 zoneinfo ### What changes were proposed in this pull request? In `test_timezone_with_pandas`, compare the series timezone via `str(dtype.tz)` instead of the pytz-specific `dtype.tz.zone` attribute. ### Why are the changes needed? pandas 3 defaults tz-aware dtypes to `zoneinfo.ZoneInfo` instead of `pytz`. `ZoneInfo` has no `.zone` attribute, so `ser1.dtype.tz.zone` raised `AttributeError: 'zoneinfo.ZoneInfo' object has no attribute 'zone'` under pandas 3. `str(dtype.tz)` yields the zone name (e.g. "Asia/Singapore") for both `pytz` (pandas 2) and `zoneinfo` (pandas 3). Part of SPARK-55139 (Support Pandas 3). ### Does this PR introduce _any_ user-facing change? No, test-only. ### How was this patch tested? `test_pyarrow_ignore_timezone` passes under pandas 3 + pyarrow 23, pandas 2 + pyarrow 23, and pandas 2 + pyarrow 22. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.8 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
HyukjinKwon
approved these changes
Jul 8, 2026
Member
|
Merged to master and branch-4.x. |
Member
|
Let's file a new JIRA next time. fixed version is diff |
HyukjinKwon
pushed a commit
that referenced
this pull request
Jul 8, 2026
…for pandas 3 zoneinfo ### What changes were proposed in this pull request? In `test_timezone_with_pandas`, compare the series timezone via `str(dtype.tz)` instead of the pytz-specific `dtype.tz.zone` attribute. ### Why are the changes needed? pandas 3 defaults tz-aware dtypes to `zoneinfo.ZoneInfo` instead of `pytz`. `ZoneInfo` has no `.zone` attribute, so `ser1.dtype.tz.zone` raised `AttributeError: 'zoneinfo.ZoneInfo' object has no attribute 'zone'` under pandas 3. `str(dtype.tz)` yields the zone name (e.g. "Asia/Singapore") for both `pytz` (pandas 2) and `zoneinfo` (pandas 3). ### Does this PR introduce _any_ user-facing change? No, test-only. ### How was this patch tested? `test_pyarrow_ignore_timezone` passes under pandas 3 + pyarrow 23, pandas 2 + pyarrow 23, and pandas 2 + pyarrow 22. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.8 Closes #57071 from fangchenli/pandas3-fix-tz-zoneinfo. Authored-by: Fangchen Li <fangchen.li@outlook.com> Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com> (cherry picked from commit 78ac879) Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
In
test_timezone_with_pandas, compare the series timezone viastr(dtype.tz)instead of the pytz-specificdtype.tz.zoneattribute.Why are the changes needed?
pandas 3 defaults tz-aware dtypes to
zoneinfo.ZoneInfoinstead ofpytz.ZoneInfohas no.zoneattribute, soser1.dtype.tz.zoneraisedAttributeError: 'zoneinfo.ZoneInfo' object has no attribute 'zone'under pandas 3.str(dtype.tz)yields the zone name (e.g. "Asia/Singapore") for bothpytz(pandas 2) andzoneinfo(pandas 3).Does this PR introduce any user-facing change?
No, test-only.
How was this patch tested?
test_pyarrow_ignore_timezonepasses under pandas 3 + pyarrow 23, pandas 2 + pyarrow 23, and pandas 2 + pyarrow 22.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.8