I have a dataframe, df
, with the following data:
ID DateTime
A 12/13/2019 6:35:48PM
A 12/13/2019 6:35:49PM
A 12/13/2019 6:35:50PM
B 12/13/2019 7:00:00PM
B 12/13/2019 7:00:05PM
C 12/13/2019 8:00:05PM
Desired outcome:
ID Duration
A 3 sec
B 5 sec
C 1 sec
Code I am performing using Python:
df.sum(group_by['ID'])
How can I calculate the duration of a column, grouping by another column?
Any suggestions will help.