2021年1月6日星期三

Python how to merge the time spans and make a bigger one

I have the following dataframe.

       padel start_time  end_time  duration  38  Padel 10   08:00:00  09:00:00        60  40  Padel 10   10:00:00  11:30:00        90  42  Padel 10   10:30:00  12:00:00        90  44  Padel 10   11:00:00  12:30:00        90  46  Padel 10   11:30:00  13:00:00        90  49  Padel 10   16:00:00  17:30:00        90  51  Padel 10   16:30:00  18:00:00        90  53  Padel 10   17:00:00  18:30:00        90  55  Padel 10   17:30:00  19:00:00        90  57  Padel 10   18:00:00  19:30:00        90  59  Padel 10   18:30:00  20:00:00        90  61  Padel 10   19:00:00  20:30:00        90  63  Padel 10   19:30:00  21:00:00        90  65  Padel 10   20:00:00  21:30:00        90  67  Padel 10   20:30:00  22:00:00        90  

I want to chose the longest timespans in between. The output I want should look like this

       padel start_time  end_time  duration  38  Padel 10   08:00:00  09:00:00        60  40  Padel 10   10:00:00  13:00:00        180  49  Padel 10   16:00:00  22:00:00        360  

I not care about duration. I can do that. but how will i merge the time spans which overlap. Thanks

https://stackoverflow.com/questions/65605199/python-how-to-merge-the-time-spans-and-make-a-bigger-one January 07, 2021 at 08:43AM

没有评论:

发表评论