I have data with time intervals:
Start End
0 2022-01-01 00:00 2022-01-03 00:00
1 2022-02-01 00:00 2022-03-01 03:00
2 2022-04-01 11:00 2022-04-10 13:00
3 2022-08-01 12:00 2022-08-07 17:00
Having a list of time points, I select intervals that contain a certain Timestamp using boolean indexing:
result = []
for t in ['2022-01-02 00:00', '2022-04-01 11:00', '2022-08-01 12:00']:
t = pd.Timestamp(t)
df_sel = df[df['Start'].le(t) & df['End'].gt(t)]
result.append(df_sel)
Resulting data frames have different lengths. What is the most efficient way to do boolean indexing with time data? Is it better to use NumPy or some other dtypes? How can I speed up my solution?