This is an automated email from the ASF dual-hosted git repository.
HyukjinKwon pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-4.x by this push:
new 46e69b11d58f [SPARK-54937][PYTHON][TEST][FOLLOWUP] Fix pytz-specific
tz assertion for pandas 3 zoneinfo
46e69b11d58f is described below
commit 46e69b11d58ff8bc32ba26890483a6725eec2e92
Author: Fangchen Li <[email protected]>
AuthorDate: Wed Jul 8 09:12:48 2026 +0900
[SPARK-54937][PYTHON][TEST][FOLLOWUP] Fix pytz-specific tz assertion 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 <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
(cherry picked from commit 78ac879919f68ade93629882d5d3262fc3b0d707)
Signed-off-by: Hyukjin Kwon <[email protected]>
---
python/pyspark/tests/upstream/pyarrow/test_pyarrow_ignore_timezone.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git
a/python/pyspark/tests/upstream/pyarrow/test_pyarrow_ignore_timezone.py
b/python/pyspark/tests/upstream/pyarrow/test_pyarrow_ignore_timezone.py
index 0337a7c1bb86..08ed807e7dcd 100644
--- a/python/pyspark/tests/upstream/pyarrow/test_pyarrow_ignore_timezone.py
+++ b/python/pyspark/tests/upstream/pyarrow/test_pyarrow_ignore_timezone.py
@@ -112,7 +112,9 @@ class PyArrowIgnoreTimeZoneTests(unittest.TestCase):
# The corresponding numpy type np.datetime64 is timezone-naive, so no
need to test
ser1 = pd.Series([ts1], dtype=pd.DatetimeTZDtype("us", tz=tz))
self.assertEqual(ser1.dtype.unit, "us")
- self.assertEqual(ser1.dtype.tz.zone, tz)
+ # Use str() rather than the pytz-specific .zone attribute: pandas 3
defaults to
+ # zoneinfo.ZoneInfo, which has no .zone. str() yields the zone name
for both.
+ self.assertEqual(str(ser1.dtype.tz), tz)
# pyarrow-backed series
ser2 = pd.Series([ts1], dtype=pd.ArrowDtype(pa_type))
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]