The following is a sample of my dataset:
index time value
0 00:00:01 12
1 00:00:06 18
2 00:00:11 28
3 00:00:15 32
4 00:00:20 51
I would like to create a for Loop that does the following function:
for t in range (00:00:01, 23:59:59, 5s):
if df.Value[t]> df.Value[t+10]:
print ('True')
else:
print('False')
The for loop will start from time= 00:00:01 (1 sec, beginning of the day) to time=23:59:59 (end of day) with 5 second increment each time. So the loop will take the value at a certain time (t) and compare it with the value at time= t+ 10 seconds. and if it is larger, it will print True; otherwise, False.
P.S.: the tricky part is that the time difference between the points isn't always 5 seconds;therefore, I would like to write a function that allows the program to take the value of the closest time.
For example:
In the fourth iteration (at index 3), the loop will will take t= 00:00:16. However, this time isn't available in the dataset; therefore, I would like to call a function that will prompt the program to take the closest time to 00:00:16 which is 00:00:15.
Please note, that the for loop above is theoretical just to show what is needed. Also, the dataset is stored in Excel sheet.
I would appreciate any help. Thanks.