I have a dataframe
df = pd.DataFrame({'id':[1,1,2,2,3],
'user':['u1', 'u1', 'u2', 'u2', 'u3'],
'date':['2021-04-25','2021-04-25','2021-04-25','2021-04-26', '2021-04-25'],
'sth_else1':['xx','yy','xx','xx','xx'], 'sth_else2':['zz','yy','zz','xx','xx']})
id user date sth_else1 sth_else2
0 1 u1 2021-04-25 xx zz
1 1 u1 2021-04-25 yy yy
2 2 u2 2021-04-25 xx zz
3 2 u2 2021-04-26 xx xx
4 3 u3 2021-04-25 xx xx
and I would like to add a column (so probably use groupby with transform?) to that dataframe that shows me the number of unique user/date combinations I have per id in the whole dataframe, so that I would get this
id user date sth_else1 sth_else2 count_per_id_user_and_date
0 1 u1 2021-04-25 xx zz 1
1 1 u1 2021-04-25 yy yy 1
2 2 u2 2021-04-25 xx zz 2
3 2 u2 2021-04-26 xx xx 2
4 3 u3 2021-04-25 xx xx 1
how would I do this?