Skip to content

Commit 9d8dff8

Browse files
Mike Phungfeefladder
Mike Phung
authored andcommitted
TST GH27994 Add test for dropping empty list / index for a DataFrame … (pandas-dev#42746)
1 parent b0bc1ec commit 9d8dff8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pandas/tests/frame/methods/test_drop.py

+23
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pandas as pd
99
from pandas import (
1010
DataFrame,
11+
DatetimeIndex,
1112
Index,
1213
MultiIndex,
1314
Series,
@@ -268,6 +269,28 @@ def test_drop_non_empty_list(self, index, drop_labels):
268269
with pytest.raises(KeyError, match="not found in axis"):
269270
DataFrame(index=index).drop(drop_labels)
270271

272+
@pytest.mark.parametrize(
273+
"empty_listlike",
274+
[
275+
[],
276+
{},
277+
np.array([]),
278+
Series([], dtype="datetime64[ns]"),
279+
Index([]),
280+
DatetimeIndex([]),
281+
],
282+
)
283+
def test_drop_empty_listlike_non_unique_datetime_index(self, empty_listlike):
284+
# GH#27994
285+
data = {"column_a": [5, 10], "column_b": ["one", "two"]}
286+
index = [Timestamp("2021-01-01"), Timestamp("2021-01-01")]
287+
df = DataFrame(data, index=index)
288+
289+
# Passing empty list-like should return the same DataFrame.
290+
expected = df.copy()
291+
result = df.drop(empty_listlike)
292+
tm.assert_frame_equal(result, expected)
293+
271294
def test_mixed_depth_drop(self):
272295
arrays = [
273296
["a", "top", "top", "routine1", "routine1", "routine2"],

0 commit comments

Comments
 (0)