Data:
z = pd.DataFrame({'a':[1,1,1,2,2,3,3],'b':[3,4,5,6,7,8,9], 'c':[10,11,12,13,14,15,16]})
My code:
gbz = z.groupby('a')
f1 = lambda x: x.loc[x['b'] > 4]['c'].mean()
f2 = lambda x: x.mean()
f3 = {'I don't know what should I write here':{'name1':f1}, 'b':{'name2': f2}}
list1 = gbz.agg(f3)
Question:
How can I put more than one column to use in function "f1" ? (This function needs two columns of the groupby object)
Expected result:
name1 name2
1 12.0 4
2 13.5 6.5
3 15.5 8.5