Skip to content

[SPARK-54937][PYTHON][TESTS][FOLLOW-UP] Fix pytz-specific tz assertion for pandas 3 zoneinfo#57071

Closed
fangchenli wants to merge 1 commit into
apache:masterfrom
fangchenli:pandas3-fix-tz-zoneinfo
Closed

[SPARK-54937][PYTHON][TESTS][FOLLOW-UP] Fix pytz-specific tz assertion for pandas 3 zoneinfo#57071
fangchenli wants to merge 1 commit into
apache:masterfrom
fangchenli:pandas3-fix-tz-zoneinfo

Conversation

@fangchenli

Copy link
Copy Markdown
Contributor

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

…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

Copy link
Copy Markdown
Member

Merged to master and branch-4.x.

@HyukjinKwon

Copy link
Copy Markdown
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>
@HyukjinKwon

Copy link
Copy Markdown
Member

Merge Summary:

Posted by merge_spark_pr.py

@fangchenli fangchenli deleted the pandas3-fix-tz-zoneinfo branch July 8, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants