Because we are focusing on the taxis movements, we would also like to know whenever the taxi has moved from a place to another between 2 different trips.
Here is an example:
We have these two trips where DOA is different than PUB, we would like to add a third trip C like this:
C is Derived by the two trips A and B.
But when should we consider possible an intermediate trip like C?
We could start by defining some rules:
Last week we have already defined good functions to compute trip_time, haversine_distance and speed; but these functions cannot operate of 2 different rows, what can we do?
What we can do is simply make a copy of our dataframe, shift it by -1 and concatenate it with the original dataframe of valid_records.