class_docstr: Provide the groupby facilities to the mixed object.
docstr: 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
docstr_tok: ["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"]
code: def _gotitem(self, key, ndim, subset=None):
      """
      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
      """
      # create a new object to prevent aliasing
      if subset is None:
          subset = self.obj
  
      # we need to make a shallow copy of ourselves
      # with the same groupby
      kwargs = {attr: getattr(self, attr) for attr in self._attributes}
  
      # Try to select from a DataFrame, falling back to a Series
      try:
          groupby = self._groupby[key]
      except IndexError:
          groupby = self._groupby
  
      self = self.__class__(
          subset, groupby=groupby, parent=self, **kwargs
      )
      self._reset_cache()
      if subset.ndim == 2:
          if is_scalar(key) and key in subset or is_list_like(key):
              self._selection = key
      return self
  
imports: import types
  from pandas.util._decorators import make_signature
  from pandas.core.dtypes.common import is_list_like, is_scalar
label_desc: Use image node_id 2 for calling the GroupByMixin obj's underlying member method code with example usage: obj._gotitem(key, ndim, subset) and returns: self