def _gotitem(self, key, ndim, subset=None):
<EOL>if subset is None:<EOL><INDENT>subset = self.obj<EOL><DEDENT>self = self._shallow_copy(subset)<EOL>self._reset_cache()<EOL>if subset.ndim == <NUM_LIT:2>:<EOL><INDENT>if is_scalar(key) and key in subset or is_list_like(key):<EOL><INDENT>self._selection = key<EOL><DEDENT><DEDENT>return self<EOL>
Sub-classes to define. Return a sliced object.

Parameters
----------
key : str / list of selections
ndim : 1,2
    requested ndim of result
subset : object, default None
    subset to act on