Summing over a multiindex level in a pandas series Summing over a multiindex level in a pandas series pandas pandas

Summing over a multiindex level in a pandas series


If you know you always want to aggregate over the first two levels, then this is pretty easy:

In [27]: data.groupby(level=[0, 1]).sum()Out[27]:A  B    277   b     37a  B    159   b     16dtype: int64