code: def groupby(obj, by, **kwds):
      if isinstance(obj, ModelSeries):
          klass = ModelSeriesGroupBy
      elif isinstance(obj, ModelFrame):
          klass = ModelFrameGroupBy
      else:  # pragma: no cover
          raise TypeError("invalid type: %s" % type(obj))
  
      return klass(obj, by, **kwds)
  
imports: import pandas
  import pandas.compat
  from pandas_ml.compat import Appender
  from pandas_ml.core.base import _BaseEstimator
  from pandas_ml.core.frame import ModelFrame
  from pandas_ml.core.generic import ModelPredictor, _shared_docs
  from pandas_ml.core.series import ModelSeries
label_desc: Use image node_id 1 for calling a global function with example usage: groupby(obj, by) and returns: klass