The following is a sample of my dataset:
index time speed
0 00:00:00 15
1 00:00:05 18
2 00:00:10 23
3 00:00:15 25
4 00:00:20 34
I would like to create a for loop that does the same function as below:
for i in range (0,5,1):
if df.speed[i] > df.speed [i+2]:
print ('Larger')
else:
print('Smaller')
However, I would like to refer to time instead of indices in the FOR loop. For example:
for t in range (00:00:00, 00:00:20 , 5s):
if df.speed[t] > df.speed [t+10s]:
print ('Larger')
else:
print('Smaller')
So the FOR LOOP will take the speed value at a certain t and compare with it the value of the speed after 10 seconds. If it is larger, then it prints Larger, otherwise, Smaller.
I appreciate any help. Thanks.