I have two dataframes with different labels, df1 and df2.
df1 contains (amongst other things) a list of time intervals (start/stop).
df2 contains a list of events with timestamps.
I want to check which time intervals in df1 include an event from df2. It doesn't matter which specific event, and it doesn't matter how many events. Yes/No is enough.
What I have (simplified):
df1
Index Start_time Stop_time (other columns...)
1 1 5
2 8 10
3 20 22
4 23 40
df2
Index Event_time (other columns...)
1 2
2 400
3 21
4 40
What I want:
df3
Index Start_time Stop_time Event Event_time(optional) (other columns...)
1 1 5 Yes 2
2 8 10 No NaN
3 20 22 Yes 21
4 23 40 Yes 40
Note that (other columns) are different in both dataframes. Therefore, a direct comparison yields the Can only compare identically-labeled DataFrame objects-error.
How to compare values in non-identically labelled pandas dataframe objects?
EDIT: This and this looks like it is applicable here, but no results so far