I have two large datasets, df1 and df2. The first dataset, df1, contains the columns 'ID' and 'actualdata'.
The second dataset, df2, contains two date fields, 'beforedate' and 'afterdate', which represent a start and end date, respectively.
My goal is to create a new column in df1 named 'match' that indicates whether the 'actualdate' for each row in df1 is between the 'beforedate’ and ‘afterdate’ of any of the observations of the same 'ID' in df2. If it is between, I want to give the 'match' column a value of 1, otherwise 0. I want to include observations of both df1 and df2 where there is no 'ID' match).
The second dataset, df2, contains two date fields, 'beforedate' and 'afterdate', which represent a start and end date, respectively.
My goal is to create a new column in df1 named 'match' that indicates whether the 'actualdate' for each row in df1 is between the 'beforedate’ and ‘afterdate’ of any of the observations of the same 'ID' in df2. If it is between, I want to give the 'match' column a value of 1, otherwise 0. I want to include observations of both df1 and df2 where there is no 'ID' match).
Comment