Pandas transforme le nombre de conditions où la condition

# use lambda function within your transform. 
# here i am checking if key3 is greater than 0
df.groupby(['key1', 'key2'])['key3'].transform(lambda x: x[x > 0].count())
Hambo