I have a dataframe, df1 with two columns representing the start and end time of task. I have another dataframe, df2 with two columns representing time and the stock available at that time. I want to create another column in df1 named as max_stock which has maximum value of stock values for a time range given by ST and ET of df1. For instance, first task has start time 7/11/2021 1:00 and end time 7/11/2021 2:00 so for this value of max_stock is maximum of values in stock column of df2 which is maximum of 10, 26, and 48 at time 7/11/2021 1:00, and 7/11/2021 1:30, and 7/11/2021 2:00, respectively.
df1
ST ET
7/11/2021 1:00 7/11/2021 2:00
7/11/2021 2:00 7/11/2021 3:00
7/11/2021 3:00 7/11/2021 4:00
7/11/2021 4:00 7/11/2021 5:00
7/11/2021 5:00 7/11/2021 6:00
7/11/2021 6:00 7/11/2021 7:00
7/11/2021 7:00 7/11/2021 8:00
7/11/2021 8:00 7/11/2021 9:00
7/11/2021 9:00 7/11/2021 10:00
df2
Time stock
7/11/2021 1:00 10
7/11/2021 1:30 26
7/11/2021 2:00 48
7/11/2021 2:30 35
7/11/2021 3:00 32
7/11/2021 3:30 80
7/11/2021 4:00 31
7/11/2021 4:30 81
7/11/2021 5:00 65
7/11/2021 5:30 83
7/11/2021 6:00 40
7/11/2021 6:30 84
7/11/2021 7:00 41
7/11/2021 7:30 15
7/11/2021 8:00 65
7/11/2021 8:30 18
7/11/2021 9:00 80
7/11/2021 9:30 12
7/11/2021 10:00 5
Required df
ST ET max_stock
7/11/2021 1:00 7/11/2021 2:00 48.00
7/11/2021 2:00 7/11/2021 3:00 48.00
7/11/2021 3:00 7/11/2021 4:00 80.00
7/11/2021 4:00 7/11/2021 5:00 81.00
7/11/2021 5:00 7/11/2021 6:00 83.00
7/11/2021 6:00 7/11/2021 7:00 84.00
7/11/2021 7:00 7/11/2021 8:00 65.00
7/11/2021 8:00 7/11/2021 9:00 80.00
7/11/2021 9:00 7/11/2021 10:00 80.00