From 5c06cbbf817b22dfb1e09453dc009254264f9fe9 Mon Sep 17 00:00:00 2001 From: antznette1 Date: Wed, 12 Nov 2025 02:30:58 +0100 Subject: [PATCH 1/2] TST: xfail test for DatetimeIndex.union across DST boundary (GH#62915) --- pandas/tests/indexes/datetimes/test_setops.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pandas/tests/indexes/datetimes/test_setops.py b/pandas/tests/indexes/datetimes/test_setops.py index 7a68cb867c94e..e2b30425d835c 100644 --- a/pandas/tests/indexes/datetimes/test_setops.py +++ b/pandas/tests/indexes/datetimes/test_setops.py @@ -60,6 +60,30 @@ def test_union3(self, sort, box): result = first.union(case, sort=sort) tm.assert_index_equal(result, expected) + +@pytest.mark.xfail(reason="see GH#62915: union across DST boundary", strict=False) +def test_union_across_dst_boundary_xfail(): + # US/Eastern DST spring-forward on 2021-03-14 at 02:00 (02:00-02:59 local time does not exist) + tz = "US/Eastern" + # Left side spans up to the missing hour window + left = date_range("2021-03-14 00:00", periods=3, freq="H", tz=tz) + # right side continues from the first valid post-DST hour + right = date_range("2021-03-14 03:00", periods=3, freq="H", tz=tz) + + # Expect a union that preserves tz and includes valid hours without duplicates + expected = DatetimeIndex( + [ + Timestamp("2021-03-14 00:00", tz=tz), + Timestamp("2021-03-14 01:00", tz=tz), + Timestamp("2021-03-14 03:00", tz=tz), + Timestamp("2021-03-14 04:00", tz=tz), + Timestamp("2021-03-14 05:00", tz=tz), + ] + ) + + result = left.union(right) + tm.assert_index_equal(result, expected) + @pytest.mark.parametrize("tz", tz) def test_union(self, tz, sort): rng1 = date_range("1/1/2000", freq="D", periods=5, tz=tz) From f487dc9e0e3c7d9ef75c07b761cfcc210719a8bc Mon Sep 17 00:00:00 2001 From: antznette1 Date: Wed, 12 Nov 2025 03:01:12 +0100 Subject: [PATCH 2/2] TST: wrap long comment to satisfy ruff E501 (GH#62915) --- pandas/tests/indexes/datetimes/test_setops.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/tests/indexes/datetimes/test_setops.py b/pandas/tests/indexes/datetimes/test_setops.py index e2b30425d835c..b2620cdae5984 100644 --- a/pandas/tests/indexes/datetimes/test_setops.py +++ b/pandas/tests/indexes/datetimes/test_setops.py @@ -63,7 +63,8 @@ def test_union3(self, sort, box): @pytest.mark.xfail(reason="see GH#62915: union across DST boundary", strict=False) def test_union_across_dst_boundary_xfail(): - # US/Eastern DST spring-forward on 2021-03-14 at 02:00 (02:00-02:59 local time does not exist) + # US/Eastern DST spring-forward on 2021-03-14 at 02:00 + # (02:00-02:59 local time does not exist) tz = "US/Eastern" # Left side spans up to the missing hour window left = date_range("2021-03-14 00:00", periods=3, freq="H", tz=tz)