def _slice(self, slicer):

        # only allow 1 dimensional slicing, but can
        # in a 2-d case be passd (slice(None),....)
        if isinstance(slicer, tuple) and len(slicer) == 2:
            if not is_null_slice(slicer[0]):
                raise AssertionError("invalid slicing for a 1-ndim "
                                     "categorical")
            slicer = slicer[1]

        _codes = self._codes[slicer]
        return Categorical(values=_codes, categories=self.categories,
                           ordered=self.ordered, fastpath=True)
Return a slice of myself.
dataset/ETHPy150Open pydata/pandas/pandas/core/categorical.py/Categorical._slice