I calculated the duration in my dataframe, but I want to get the duration in seconds instead of what it gives (0 days, 00:10:25
and so on):
df['duration'] = df['end_date'] - df['start_date']
df.head(2)
started_at ended_at start_date end_date duration
0 2021-01-23 16:14:19 2021-01-23 16:24:44 2021-01-23 16:14:19 2021-01-23 16:24:44 0 days 00:10:25
1 2021-01-27 18:43:08 2021-01-27 18:47:12 2021-01-27 18:43:08 2021-01-27 18:47:12 0 days 00:04:04
I tried some solutions from here, but I'm not really sure how to do it right, nothing works; for example I tried this:
df['duration'] = datetime.timedelta.total_seconds(df['duration'])
but it says
TypeError: descriptor 'total_seconds' for 'datetime.timedelta' objects doesn't apply to a 'Series' object