def _gotitem(self, key, ndim, subset=None):
<EOL>if subset is None:<EOL><INDENT>subset = self.obj<EOL><DEDENT>kwargs = {attr: getattr(self, attr) for attr in self._attributes}<EOL>try:<EOL><INDENT>groupby = self._groupby[key]<EOL><DEDENT>except IndexError:<EOL><INDENT>groupby = self._groupby<EOL><DEDENT>self = self.__class__(subset,<EOL>groupby=groupby,<EOL>parent=self,<EOL>**kwargs)<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 : string / list of selections
ndim : 1,2
    requested ndim of result
subset : object, default None
    subset to act on