Pandas Groupby apply function to count values greater than zero
I am using groupby and agg in the following manner:
df.groupby('group')['a'].agg({'mean' : np.mean, 'std' : np.std})
and I would like to also count the values above zero in the same column ['a']
the following line does the count as I want,
sum(x > 0 for x in df['a'])
but I can't get it work when applying to groupby.
Following an example for applying a pandas calculation to a groupby I tried:
df.groupby('group')['a'].apply(sum(x > 0 for x in df['a']))
but I get an error message: AttributeError: 'numpy.int32' object has no attribute 'module'
Can anybody please suggest how this might be done?