Skip to content

Commit 2127733

Browse files
mroeschkejreback
authored andcommitted
TST: drop tz-aware timestamp from DatetimIndex with DST transition (#23479)
1 parent 17e3c5c commit 2127733

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

doc/source/whatsnew/v0.24.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,7 @@ Timezones
11501150
- Bug in :meth:`DatetimeIndex.unique` that did not re-localize tz-aware dates correctly (:issue:`21737`)
11511151
- Bug when indexing a :class:`Series` with a DST transition (:issue:`21846`)
11521152
- Bug in :meth:`DataFrame.resample` and :meth:`Series.resample` where an ``AmbiguousTimeError`` or ``NonExistentTimeError`` would raise if a timezone aware timeseries ended on a DST transition (:issue:`19375`, :issue:`10117`)
1153+
- Bug in :meth:`DataFrame.drop` and :meth:`Series.drop` when specifying a tz-aware Timestamp key to drop from a :class:`DatetimeIndex` with a DST transition (:issue:`21761`)
11531154

11541155
Offsets
11551156
^^^^^^^

pandas/tests/test_multilevel.py

+13
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,19 @@ def test_drop_level_nonunique_datetime(self):
19311931
expected = df.loc[idx != 4]
19321932
tm.assert_frame_equal(result, expected)
19331933

1934+
@pytest.mark.parametrize('box', [Series, DataFrame])
1935+
def test_drop_tz_aware_timestamp_across_dst(self, box):
1936+
# GH 21761
1937+
start = Timestamp('2017-10-29', tz='Europe/Berlin')
1938+
end = Timestamp('2017-10-29 04:00:00', tz='Europe/Berlin')
1939+
index = pd.date_range(start, end, freq='15min')
1940+
data = box(data=[1] * len(index), index=index)
1941+
result = data.drop(start)
1942+
expected_start = Timestamp('2017-10-29 00:15:00', tz='Europe/Berlin')
1943+
expected_idx = pd.date_range(expected_start, end, freq='15min')
1944+
expected = box(data=[1] * len(expected_idx), index=expected_idx)
1945+
tm.assert_equal(result, expected)
1946+
19341947
def test_drop_preserve_names(self):
19351948
index = MultiIndex.from_arrays([[0, 0, 0, 1, 1, 1],
19361949
[1, 2, 3, 1, 2, 3]],

0 commit comments

Comments
 (0)