I want to know how many people put GRADE1, 2, 3, 4, and 5 among the groups of people who made ratings 1 time, between 2 and 3 times, and more than 3 times. For example, a group of people doing grades 1 time contains individuals with the identifier 2and 4. This group has only one rating 5and one rating 1.
df =
ID_PERSON EVALUATION_GRADE
1 2
1 2
1 3
1 5
2 5
3 2
3 5
3 1
4 1
5 2
5 1
5 1
The result should be as follows:
result =
FREQUENCY_GROUP GRADE_1 GRADE_2 GRADE_3 GRADE_4 GRADE_5
"1 time" 1 0 0 0 1
"2-3 times" 3 2 0 0 1
"> 3 times" 0 2 1 0 1
If I do this df.groupby(['EVALUATION_GRADE']).agg({'ID_PERSON': 'count'}).reset_index(), I get the total number of people who put the 1, 2, 3, 4and 5. However, how can I break them down into frequency groups?
source
share