I have an event file (very similar to a log file) that logs event information that includes user data and time stamps. The events have an ordering for each user. So event E1 occurs before E2 that occurs before E3 and so on. For each user, I need to calculate the time durations to transition from E1 to E2 and so on. The event file has a line for each event. Naively, to do this I can group by the user and event time (for example in pandas) and then parse the group by result line by line. For each new line, I can calculate the time duration. Since it appears that this should be a fairly common data extraction task. Is there a standard way to do this rather than how I have described this above?