I have a dataframe:
id value_type
1 b
1 a
1 a
2 a
3 a
3 b
I want to count value type within a group with 0 if it is absent in group.so desired result is:
id value_type cnt
1 b 1
1 a 2
2 a 1
2 b 0
3 a 1
3 b 1
How could I do that? I tried groupby().size() but it counts without 0 if it is absent in group
