I have a pandas DataFrame containing timestamped events. Each event has a start time and end time:
start end other_vars
100 120 ...
150 151 ...
160 170 ...
200 210 ...
Is there a clean way to calculate time between events (e.g. the span between the end of the previous event and the start of this event) in pandas?
start end between other_vars
100 120 NA ...
150 151 30 ...
160 170 9 ...
200 210 30 ...
I think the easiest way to accomplish this is to subtract one shifted column from the other. The shift function does exactly that, it shifts an array by a default of one index.