0
votes

I have this example df:

start_date   end_date id
22-07-2022 28-07-2022  A
22-07-2022 28-07-2022  B
22-07-2022 17-08-2022  A

I need to obtain this result:

start_date   end_date id
22-07-2022 28-07-2022  A
22-07-2022 28-07-2022  B
29-07-2022 17-08-2022  A

To put it in words, I need to copy the earliest end_date + 1 day from one row with the same id into the another row's start_date, so the dates don't overlap. There will always be 2 rows max per id and the start_date will be the same for both of them.

Right now I'm trying to use a for loop adding conditions but I guess there's a more Pythonic way to do this using pandas functions. Any hint?

Thanks