diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi index 186a45419..a68a4f589 100644 --- a/pandas-stubs/core/frame.pyi +++ b/pandas-stubs/core/frame.pyi @@ -136,11 +136,7 @@ class _LocIndexerFrame(_LocIndexer): | MaskType | list[HashableT] | tuple[ - IndexType - | MaskType - | slice - | list[HashableT] - | tuple[str | int | slice, ...], + IndexType | MaskType | list[HashableT] | Hashable, list[HashableT] | slice | Series[bool] | Callable, ], ) -> DataFrame: ... diff --git a/tests/test_frame.py b/tests/test_frame.py index b54adfb07..1ccb6b592 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -1741,3 +1741,12 @@ def test_xs_key() -> None: check( assert_type(df.xs(0, level="foo"), Union[pd.DataFrame, pd.Series]), pd.DataFrame ) + + +def test_loc_slice() -> None: + # GH 277 + df1 = pd.DataFrame( + {"x": [1, 2, 3, 4]}, + index=pd.MultiIndex.from_product([[1, 2], ["a", "b"]], names=["num", "let"]), + ) + check(assert_type(df1.loc[1, :], pd.DataFrame), pd.DataFrame)