diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index d38b54dae..6b1cf01b9 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -198,6 +198,7 @@ class _LocIndexerSeries(_LocIndexer, Generic[S1]): | list[str] | slice | _IndexSliceTuple + | Sequence[_IndexSliceTuple] | Callable ), # _IndexSliceTuple is when having a tuple that includes a slice. Could just diff --git a/tests/test_series.py b/tests/test_series.py index 8bbe0f8d7..ea6110ec5 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -176,6 +176,20 @@ def test_multiindex_loc() -> None: check(assert_type(s.loc[1, "a"], int), np.int_) +def test_multiindex_loc_str_tuple() -> None: + s = pd.Series( + [1, 2, 3, 4, 5, 6], + index=pd.MultiIndex.from_product([["A", "B"], ["c", "d", "e"]]), + dtype=int, + ) + check(assert_type(s.loc[("A", "c")], int), np.int_) + check( + assert_type(s.loc[[("A", "c"), ("B", "d")]], "pd.Series[int]"), + pd.Series, + np.int_, + ) + + def test_types_boolean_indexing() -> None: s = pd.Series([0, 1, 2]) s[s > 1]