I have a data frame as follows:
userID Correct
0 1050 F
1 1050 T
2 1050 T
3 1050 F
4 1050 F
5 1050 F
6 1050 F
7 1050 F
8 1050 F
9 1050 F
10 1051 F
11 1051 F
12 1051 F
13 1051 F
14 1051 F
15 1051 T
16 1051 F
17 1051 F
18 1051 F
19 1051 T
What I want to do is to count the number of T's for the "Correct" column for every user. That is, after we grouped the data frame by userID, I want a column that has the number of T's for that user.
Here is what I have done but it clearly is wrong:
df.groupby('userID').agg({'Correct': lambda x: (x == T).count()})