I have a dataframe which looks like this:
A B Start_Date
1 4 2003-05-22
2 6 2003-05-31
....
57 406 2018-09-08
I want to get the value which is at or after a few years from the Start_Date. For instance I want to know the value of column B which will be at a date less than or equal to 10 years from the Start_Date for the corresponding value. So this will look something like this:
A B Start_Date D
1 4 2003-05-22 <value of B on or before (last value before) 2013-05-22>
2 6 2003-05-31 <value of B on or before (last value before) 2013-05-31>
....
57 406 2018-09-08 <value of B on or before (last value before) 2028-09-08>
When I try something like this ('Start_Date plus 10' is just another column with 10 years added to the Start_Date column)
df['D']=df[df['Start Date']<=df['Start_Date plus 10']]['B'].max()
It just gives out the maximum value for column B which is understandable, however not my end objective. Please help with suggestions on this. Please let me know if there is ambiguity in the question or if anything needs to be clarified further. Thank you for taking the time to read this and answer the question.