I have a dataframe in pandas
val1 val2 val3 time
a b c 0
d e f 5
g h i 7
j k l 4
c a q 9
m e t 2
g n y 1
v k l 0
and timesteps = [0, 3, 8]
And I want to create a new column that is the the maximal value of an elemet from timesteps that is lower than row["time"]
For example, here the new column will be [0,3,3,3,8,0,0,0]
What is the best way to do so?