I have the following type of input data say df1 :
idtag alpha type
1 abc 1a
1 avg 1a
1 rgw 2a
1 rrw 2a
2 rgw 2a
2 abc 1a
3 abc 1a
3 rqw 2a
The requirement is to retrieve the "type" and count of each "type" value for every "idtag" value into a new df2 like shown below:
idtag 1a 2a
1 2 2
2 1 1
3 1 1
This is what I used for groupby:
df1.groupby(['idtag','type']).count()
But, I am having trouble in shaping the results into producing df2. Appreciate the help.
Thank you.