Skip to content

Commit 46af282

Browse files
committed
add some droplevel tests
1 parent 05d5147 commit 46af282

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/indexes/test_indexes.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,6 @@ def test_datetimeindex_where() -> None:
15261526

15271527

15281528
def test_index_set_names() -> None:
1529-
"""Test Index.where with multiple types of other GH1419."""
15301529
idx = pd.Index([1, 2])
15311530
check(
15321531
assert_type(idx.set_names("chinchilla"), "pd.Index[int]"), pd.Index, np.integer
@@ -1546,3 +1545,15 @@ def test_index_set_names() -> None:
15461545
)
15471546
mi = cast("pd.MultiIndex", pd.Index([(1,)]))
15481547
check(assert_type(mi.set_names(1), pd.MultiIndex), pd.MultiIndex, tuple)
1548+
1549+
1550+
def test_index_droplevel() -> None:
1551+
idx = pd.Index([1, 2])
1552+
check(assert_type(idx.droplevel([]), "pd.Index[int]"), pd.Index, np.integer)
1553+
mi = pd.MultiIndex.from_arrays([[1, 2, 3], [4, 5, 6]], names=["elk", "owl"])
1554+
check(assert_type(mi.droplevel([]), pd.MultiIndex | pd.Index), pd.MultiIndex)
1555+
check(assert_type(mi.droplevel([0]), pd.MultiIndex | pd.Index), pd.Index)
1556+
check(assert_type(mi.droplevel((0,)), pd.MultiIndex | pd.Index), pd.Index)
1557+
check(assert_type(mi.droplevel(["elk"]), pd.MultiIndex | pd.Index), pd.Index)
1558+
check(assert_type(mi.droplevel(("elk",)), pd.MultiIndex | pd.Index), pd.Index)
1559+
check(assert_type(mi.droplevel(0), pd.MultiIndex | pd.Index), pd.Index)

0 commit comments

Comments
 (0)