def __getitem__(self, key):
if isinstance(key, (int, np.integer)):<EOL><INDENT>i = self._codes[key]<EOL>if i == -<NUM_LIT:1>:<EOL><INDENT>return np.nan<EOL><DEDENT>else:<EOL><INDENT>return self.categories[i]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return self._constructor(values=self._codes[key],<EOL>dtype=self.dtype, fastpath=True)<EOL><DEDENT>
Return an item.