def _gotitem(self, key, ndim, subset=None):
if ndim == <NUM_LIT:2>:<EOL><INDENT>if subset is None:<EOL><INDENT>subset = self.obj<EOL><DEDENT>return DataFrameGroupBy(subset, self.grouper, selection=key,<EOL>grouper=self.grouper,<EOL>exclusions=self.exclusions,<EOL>as_index=self.as_index,<EOL>observed=self.observed)<EOL><DEDENT>elif ndim == <NUM_LIT:1>:<EOL><INDENT>if subset is None:<EOL><INDENT>subset = self.obj[key]<EOL><DEDENT>return SeriesGroupBy(subset, selection=key,<EOL>grouper=self.grouper)<EOL><DEDENT>raise AssertionError("<STR_LIT>")<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