As a minimal example consider the following two df (notice their sizes are not equal):
df
min_val max_val
0 0 4
1 5 9
2 10 14
3 15 19
4 20 24
5 25 29
df1
val
0 1
1 6
2 2
3 Nan
4 34
I am trying to check whether each value in df1 can be found within any pair in df. The output should be a new dataframe that will contain the val column of df1 plus the pair within which it was found plus an extra column with a name tag let's say 'within' and 'not within'. So the output should look like:
val min_val max_val nameTag
0 1 0 4 within
1 6 5 9 within
2 2 0 4 within
3 Nan Nan Nan not within
4 34 Nan Nan not within
So far, any solutions I have found do the searches line-by-line missing the val 2 in df1 which is within the pair 0-4 in df (some posts that did not work for me HERE, and HERE).
Any pointers/advice/solutions will be much appreciated. Thanks