I have a two dataframes:
email_date_df:
email_id |customer_id| email_date | email_opened
001 | 1000 | 03-02-21 | 1
002 | 1001 | 03-22-21 | 0
003 | 1002 | 04-02-21 | 1
004 | 1003 | 05-02-21 | 1
transaction_df:
trans_id |customer_id| trans_date | amount
001 | 1000 | 03-04-21 | $10
002 | 1001 | 04-30-21 | $24
003 | 1001 | 05-02-21 | $14
004 | 1003 | 04-10-21 | $149
I want to understand for each email sent to a customer, was there a transaction that happened within 30 days. I merged on date frames based on customer_id but have too much duplicate rows and data.
Is there a way I can search through transaction_df for each row in email_date_df to see if there was a transaction within 30 days?
The output would look like:
email_date_df:
email_id |customer_id| email_date | email_opened | transaction_witin_30_days
001 | 1000 | 03-02-21 | 1 | 1
002 | 1001 | 03-22-21 | 0 | 0
003 | 1002 | 04-02-21 | 1 | 0
004 | 1003 | 05-02-21 | 1 | 0