I have the above table, How to create the below table in pandas, it si like if two events are falling on same date, we need count as 2 for each [duplicate]
Solution 1:
Call transform
this will return a Series aligned with the original df:
In [223]:
df['count'] = df.groupby('group')['group'].transform('count')
df
Out[223]:
org group count
0 org1 1 2
1 org2 1 2
2 org3 2 1
3 org4 3 3
4 org5 3 3
5 org6 3 3