wesm/pandas — Issue #579: apply over groups api for DataFrames
Author: gregglind
Created: 2012-01-05 22:32:56+00:00
State: open

I am not sure what the right solution is, but

dfext.head(10).groupby(['id','name']).apply(lambda g: DataFrame({'i':[g.isCompatible.sum()],}).ix[0])

to get a 'select' over multiple variables seems wrong/fragile/complex.

I know we are busy here trying to reinvent sql badly, but maybe this should get sugar:

dfext.groupby([vars]).select({k1:op1, k2:op2})

where some magic can happen in there.

Even simplifying down the *this is a one row data frame* part would remove a lot of the snarl.

(Use case: typically, I group, and I want multiple stats on multiple columns, or some stat that is a combination of multiple columns.... pandas.DataFrame is like ``itertools.groupby`` on steroids and with less hassle!)

It is possible of course that I might want Pivots or something. If so, correct me.