diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index 62941a23c6459..73258e09522a2 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -529,13 +529,6 @@ def _convert_list_indexer(self, keyarr): return self.get_indexer_for(keyarr) - @doc(Index._maybe_cast_slice_bound) - def _maybe_cast_slice_bound(self, label, side: str, kind): - if kind == "loc": - return label - - return super()._maybe_cast_slice_bound(label, side, kind) - # -------------------------------------------------------------------- def _is_comparable_dtype(self, dtype): diff --git a/pandas/tests/indexing/test_categorical.py b/pandas/tests/indexing/test_categorical.py index f104587ebbded..11943d353e8c8 100644 --- a/pandas/tests/indexing/test_categorical.py +++ b/pandas/tests/indexing/test_categorical.py @@ -469,7 +469,11 @@ def test_ix_categorical_index_non_unique(self): def test_loc_slice(self): # GH9748 - with pytest.raises(KeyError, match="1"): + msg = ( + "cannot do slice indexing on CategoricalIndex with these " + r"indexers \[1\] of type int" + ) + with pytest.raises(TypeError, match=msg): self.df.loc[1:5] result = self.df.loc["b":"c"]