Using the Pandas package in python, I would like to sum (marginalize) over one level in a series with a 3-level multiindex to produce a series with a 2 level multiindex. For exa
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 37 a B 159 b 16 dtype: int64