def __getitem__(self, key):
        if isinstance(key, (int, np.integer)):
            i = self._codes[key]
            if i == -1:
                return np.nan
            else:
                return self.categories[i]
        else:
            return Categorical(values=self._codes[key],
                               categories=self.categories,
                               ordered=self.ordered,
                               fastpath=True)
Return an item.
dataset/ETHPy150Open pydata/pandas/pandas/core/categorical.py/Categorical.__getitem__