I have 2 dataframes I would like to merge. Both continue for 300 seconds (in the start column). They are below.
df_1:
color start stop
0 blue 2.72 2.85
1 green 2.86 3.09
2 blue 3.10 3.47
3 green 3.48 4.69
4 blue 4.70 5.97
5 green 5.98 7.07
df_2:
confidence start
0 .11 2.79
1 .78 2.99
2 .65 3.04
3 .22 3.43
4 .54 3.61
5 .99 3.99
6 .52 4.24
7 .63 4.31
8 .71 4.67
9 .82 4.85
10 .81 5.09
11 .33 5.26
12 .31 5.69
13 .44 5.99
14 .55 6.22
15 .81 6.43
16 .31 6.93
17 .32 7.01
… and so on
I want to merge the aggregated mean value for df_2['confidence'] when df_2['start'] value is in between the df_1['start'] and df_1['stop'] value.
Ideally, it looks like this:
color start stop confidence
0 blue 2.72 2.85 .11
1 green 2.86 3.09 .72
2 blue 3.10 3.47 .22
3 green 3.48 4.69 .68
4 blue 4.70 5.97 .57
5 green 5.98 7.07 .49
Thanks!