Skip to content
Advertisement

Calculate TimeDiff in Pandas based on a column values

Having a dataframe like that:

enter image description here

Desirable result is to get aggregated IDs with time diffs between Start and End looking like that:

enter image description here

Tried simple groupings and diffs but it does not work:

How this task can be done in pandas? Thanks!

Advertisement

Answer

A possible solution is to join the table on itself like this:

Output:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement