class_docstr:     An abstract statistical model class for panel (longitudinal) datasets.
  
      Parameters
      ----------
      endog : array_like or str
          If a pandas object is used then endog should be the name of the
          endogenous variable as a string.
  #    exog
  #    panel_arr
  #    time_arr
      panel_data : pandas.Panel object
  
      Notes
      -----
      If a pandas object is supplied it is assumed that the major_axis is time
      and that the minor_axis has the panel variable.
      
class_docstr_tok: ["An","abstract","statistical","model","class","for","panel","(","longitudinal",")","datasets",".","Parameters","--","--","--","--","--","endog",":","array_like","or","str","If","a","pandas","object","is","used","then","endog","should","be","the","name","of","the","endogenous","variable","as","a","string",".","#","exog","#","panel_arr","#","time_arr","panel_data",":","pandas.Panel","object","Notes","--","--","-","If","a","pandas","object","is","supplied","it","is","assumed","that","the","major_axis","is","time","and","that","the","minor_axis","has","the","panel","variable","."]
docstr: Get group means of X by time or by panel.
  
  index default is panel
docstr_tok: ["Get","group","means","of","X","by","time","or","by","panel",".","index","default","is","panel"]
code: def _group_mean(self, X, index="oneway", counts=False, dummies=False):
      """
      Get group means of X by time or by panel.
  
      index default is panel
      """
      if index == "oneway":
          Y = self.panel
          uniq = self.paneluniq
      elif index == "time":
          Y = self.time
          uniq = self.timeuniq
      else:
          raise ValueError("index %s not understood" % index)
      print(
          Y,
          uniq,
          uniq[:, None],
          len(Y),
          len(uniq),
          len(uniq[:, None]),
          index,
      )
      # TODO: use sparse matrices
      dummy = (Y == uniq[:, None]).astype(float)
      if X.ndim > 1:
          mean = np.dot(dummy, X) / dummy.sum(1)[:, None]
      else:
          mean = np.dot(dummy, X) / dummy.sum(1)
      if counts is False and dummies is False:
          return mean
      elif counts is True and dummies is False:
          return mean, dummy.sum(1)
      elif counts is True and dummies is True:
          return mean, dummy.sum(1), dummy
      elif counts is False and dummies is True:
          return mean, dummy
  
imports: from functools import reduce
  import numpy
  from statsmodels.regression.linear_model import GLS
  from pandas import Panel
label_desc: Use image node_id 4 for calling the PanelModel obj's underlying member method code with example usage: obj._group_mean(X, index, counts, dummies) and returns: mean, mean,  dummy, mean,  dummy,  dummy, mean,  dummy