Basically, I have a list of arrival and departure timings. In the picture below, i = 3 and i = 4 has departure 0. What I am looking to achieve is to take i=2's departure (as my last known), and i=5's departure (as my next known), take the difference (14:44:39 - 14:41:03) and divide it equally across the missing values I have, which is i=3 and i=4. This is not a fixed pattern and it should be dynamic (i.e, sometimes I can have 2, 3 or n number of missing values)
So my question is, how can I dynamically (or recursively) check what is my next known number and divide the differences equally among the missing values that I have?
In this example, the difference between my last known and next known is 216 seconds. Since there are 3 intervals between i=2 to i=3, i=3 to i=4 and i=4 to i=5 my timestamp for my i=3 is 14:42:15 and i=4 is 14:43:27 (72s).

To solve this problem, I converted each
Departuredata item into atimestamps_in_secondsin order to calculate the linear interpolation between themtimestamps_interpolatedbefore converting the calculated data into the desired formatdeparture_interpolated.Here's the output (consider the departure_interpolated column):