Several questions posted about transforming pandas groupby object to DataFrame seem to involve aggregation, as e.g. count()
here.
Can a groupby object be converted to a DataFrame without aggregating, where the group names become level 0 of a MultiIndex? and can this process be iterated?
from pandas import DataFrame as DF
df = DF.from_dict({'a':1, 'b':2, 'c':3, 'd':4, 'e':5}, orient='index')
would like the output of the grouping:
df.groupby(lambda x: df[0][x]%2)
converted to this form:
DF.from_dict({0:{'b':2,'d':4},1:{'a':1,'c':3,'e':5}},orient='index').stack().to_frame()
(besides the point, why are values converted to floats?)