groupby calculating average with timestamp field

  dataframe, pandas, python

I have this df:

user_id |  timestamp    
0      2019-04-25T13:30:18  

0   2019-04-25T13:31:40

1   2019-04-26T11:15:00

1   2019-04-26T11:15:35

I need groupby user_id subtracting timestamp column:

0 01:22

1 00:35

I already tried use:

 mean()
 transform('min')

and

transform(lambda x: (x.max()-x.min()).days)

but none of these worked, does anyone know how to do date-time operations on pandas?

Source: Python Questions

LEAVE A COMMENT