我有两个这样的数据框:
df1
email datetimecreated
1@1.com 2019-02-07 20:47:00
df2
email datetimecreated
1@1.com 2019-02-12 20:47:00
我想创建以下逻辑:
1. check if email field in df2 is present in df1
if email address is present, then:
2. check if DatetimeCreated in df1 is greater than TODAY-90 days
如果两个都为TRUE,则不要将df2中的行追加到df1中。
我正在像这样检查日期:
from datetime import datetime, timedelta
df1 = df1[df1.DateTimeCreated >= (datetime.today() - timedelta(90))]
我正在像这样检查电子邮件:
boolean = session_final_101.EmailAddress.iat[0] in df3
如何合并这两个语句?
我尝试过:
if boolean == False:
Winner_final = pd.concat([df1, df2], ignore_index=True,sort=False)
但是布尔变量始终为false,我不确定自己在做什么错。