I have this datafarme:
df = pd.DataFrame(
    {'cn':[1,1,1,1,2,2,2], 'date': ['01/10/2017', '02/09/2016', '02/10/2016','01/20/2017', '05/15/2017', '02/10/2016', '02/10/2018'],
     'score':[4,10,6, 5, 15, 7, 8]})
    cn  date    score
0   1   01/10/2017  4
1   1   02/09/2016  10
2   1   02/10/2016  6
3   1   01/20/2017  5
4   2   05/15/2017  15
5   2   02/10/2016  7
6   2   02/10/2018  8
I have these two functions:
def total_count_phq9_BOF_activation (grf):
    s = grf.score.count()
    return s
def first_phq9_BOF_activation (grf):
    value =grf[grf.score==grf.score.max()].date
    return value
I used this solution (1) to use these two functions for the apply method:
df.groupby('cn').apply (lambda x: pd.Series({"first_phq9_BOF_activation": first_phq9_BOF_activation , "total_count_phq9_BOF_activation": total_count_phq9_BOF_activation}))
But it did not work. Would you please let me know what part of my code is wrong?
 
    