I have the following data frame df1 :
id | action |
----|--------|
1 | A |
1 | A |
2 | C |
3 | D |
2 | B |
2 | C |
1 | B |
3 | D |
1 | D |
3 | A |
I want to count the frequency that the value action appear for each user, and put this value in new column. I want to get the following data frame :
id | action=A | action=B | action=C |
----|----------|----------|----------|
1 | 2 | 1 | 0 |
2 | 0 | 1 | 2 |
3 | 1 | 0 | 0 |