这是我在此处的SQL尝试的交叉发布: Comparing with other rows in table
所以我尝试了,但是没用:
df3[df3['activity_date']>=df2['activity_date']+pd.to_timedelta(59,unit='d')]
样本数据:
anon_id|signup_date|activity_date|
__________________________________
123 |01-01-2019 |02-01-2019 |
123 |01-01-2019 |02-02-2019 |
123 |01-01-2019 |02-03-2019 |
123 |01-01-2019 |02-04-2019 |
想要:
anon_id|signup_date|activity_date| active
__________________________________
123 |01-01-2019 |02-01-2019 | yes
123 |01-01-2019 |02-02-2019 | yes
123 |01-01-2019 |02-03-2019 | no
123 |01-01-2019 |02-04-2019 | no
如果在 activity_date 的60天之内再次出现相同的 anon_id , ,则Active是一个用布尔值填充的列那排的有人帮我做这个熊猫专栏吗?