I am using pandas version 1.0.5
The example dataframe below lists time intervals, recorded over three days, and I seek where some time intervals overlap every day.
For example, one of the overlapping time across all the three dates (yellow highlighted) is 1:16 - 2:13. The other (blue highlighted) would be 18:45 - 19:00
So my expected output would be like: [57,15] because
- 57 - Minutes between 1:16 - 2:13.
- 15 - Minutes between 18:45 - 19:00
Please use this generator of the input dataframe:
import pandas as pd
dat1 = [
['2023-12-27','2023-12-27 00:00:00','2023-12-27 02:14:00'],
['2023-12-27','2023-12-27 03:16:00','2023-12-27 04:19:00'],
['2023-12-27','2023-12-27 18:11:00','2023-12-27 20:13:00'],
['2023-12-28','2023-12-28 01:16:00','2023-12-28 02:14:00'],
['2023-12-28','2023-12-28 02:16:00','2023-12-28 02:28:00'],
['2023-12-28','2023-12-28 02:30:00','2023-12-28 02:56:00'],
['2023-12-28','2023-12-28 18:45:00','2023-12-28 19:00:00'],
['2023-12-29','2023-12-29 01:16:00','2023-12-29 02:13:00'],
['2023-12-29','2023-12-29 04:16:00','2023-12-29 05:09:00'],
['2023-12-29','2023-12-29 05:11:00','2023-12-29 05:14:00'],
['2023-12-29','2023-12-29 18:00:00','2023-12-29 19:00:00']
]
df = pd.DataFrame(dat1,columns = ['date','Start_tmp','End_tmp'])
df["Start_tmp"] = pd.to_datetime(df["Start_tmp"])
df["End_tmp"] = pd.to_datetime(df["End_tmp"])

This solution uses:
Method:
Number of documented days: (as in Python: Convert timedelta to int in a dataframe)
Additive landscape:
Keep only overlaps over all days: (red line, n=3)
Extract overlap ranges and their lengths
Final output:
[57, 15]