I have a DataFrame which has start_date, end_date and corresponding bucket column. I want to map another column of dates in the corresponding date range and get its bucket.
The dataframe(df1) looks like as follows:
start_date end_date bucket
2017-06-01 2017-12-31 1
2018-06-01 2018-12-31 2
2019-06-01 2019-12-31 3
2020-06-01 2020-12-31 4
There are total 80 rows in df1.
Dataframe df2 looks like:
Dates
2019-08-28
2020-09-15
2017-09-13
2018-07-22
df2 also has 80 rows.
Basically, the Dates column in df2 has to be checked against every date range in df1 and placed against its corresponding range in a new column in df1.
Expected output :
start_date end_date bucket Dates
2017-06-01 2017-12-31 1 2017-09-13
2018-06-01 2018-12-31 2 2018-07-22
2019-06-01 2019-12-31 3 2019-08-28
2020-06-01 2020-12-31 4 2020-09-15