'Get group means of X by time or by panel.
index default is panel'

def _group_mean(self, X, index='oneway', counts=False, dummies=False):

    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)
    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 == False) and (dummies == False)):
        return mean
    elif ((counts == True) and (dummies == False)):
        return (mean, dummy.sum(1))
    elif ((counts == True) and (dummies == True)):
        return (mean, dummy.sum(1), dummy)
    elif ((counts == False) and (dummies == True)):
        return (mean, dummy)
