Is it possible to directly compute the product (or for example sum) of two columns without using
grouped.apply(lambda x: (x.a*x.b).sum()
It is much (less than half the time on my machine) faster to use
df['helper'] = df.a*df.b
grouped= df.groupby(something)
grouped['helper'].sum()
df.drop('helper', axis=1)
But I don't really like having to do this. It is for example useful to compute the weighted average per group. Here the lambda approach would be
grouped.apply(lambda x: (x.a*x.b).sum()/(df.b).sum())
and again is much slower than dividing the helper by b.sum().