I have two simple dataframes. I would like to merge the two where special_date >= first_date and <= second_date and is the largest possible date.
ID | special_date |
0 11 | 2019-04-06 |
1 11 | 2019-04-09 |
2 11 | 2019-06-03 |
3 11 | 2019-03-11 |
ID | first_date | second_date |
0 11 | 2019-04-03 | 2019-04-09 |
1 11 | 2019-05-02 | 2019-05-14 |
2 11 | 2019-05-20 | 2019-06-05 |
3 11 | 2019-03-03 | 2019-03-07 |
Desired output:
ID | first_date | special_date | second_date |
0 11 | 2019-04-03 | 2019-04-09 | 2019-04-09 |
1 11 | 2019-05-02 | NaN | 2019-05-14 |
2 11 | 2019-05-20 | 2019-06-03 | 2019-06-05 |
3 11 | 2019-03-03 | NaN | 2019-03-07 |