wesm/pandas — Issue #573: flatten, multiIndex, agg, groupby
Author: gregglind
Created: 2012-01-04 22:00:15+00:00
State: open

Maybe this is even simpler, but how does one turn a MultiIndex back into a bunch of columns?

aaa = subby.groupby(['fxVersion','operatingSystem','updateChannel'])['isCompatible'].agg(dict(sum=np.sum,pct=lambda x: 100*np.mean(x),count=lambda x: len(x)))

So far, this is the best I have:

pandas.DataFrame(map(list,aaa.index.get_tuple_index()),columns=aaa.index.names)

Maybe it is just me, but I just don't get what MultiIndex is trying to do :) I have them after groupby().agg. When ``as_level=False`` is on, some types of ``agg`` don't work. Something here doesn't quite gel for me!