Skip to content
Advertisement

Tag: timedelta

How to get grouped cumulative duration in pandas?

I have the following data: id encounter_key datetime 1 111 2019-04-14 1 111 2019-04-14 1 111 2019-07-18 1 122 2019-09-02 2 211 2019-10-03 2 211 2020-10-03 I want to find the cumulative duration, grouped by id and encounter_key to achieve the following: id encounter_key datetime cum_duration_days 1 111 2019-04-14 0 1 111 2019-04-14 0 1 111 2019-07-18 95 1 122

Advertisement