mu /= np.nansum(w, axis=axis)
index = self.panel.minor_axis if group == "entity" else self.panel.major_axis
out = DataFrame(mu.T, index=index, columns=self.vars)
reindex = self.entities if group == "entity" else self.time
out = out.loc[reindex]
return out
After Change
level = 0 if group == "entity" else 1
if weights is None:
mu = self._frame.groupby(level=level).mean()
else:
w = weights.values2d
frame = self._frame.copy()
frame = w * frame