So I have two data frames. Df1 has names and values as follows:
| Source | Target | volume |
|---|---|---|
| dog | cat | 3 |
| cat | rat | 2 |
Df2 has range for each name as follows:
| name | min | max |
|---|---|---|
| dog | 1 | 2 |
| cat | 1 | 3 |
what I would like to achieve is to check if the values in source or target columns in df1 exist in name column in df2, and if they exist to check if the volume is between them min and max values and result a data frame as shown below:
| Source | Target | volume | S. in range | S. min | S. max | T. in range | T. min | T.max |
|---|---|---|---|---|---|---|---|---|
| dog | cat | 3 | No | 1 | 2 | Yes | 1 | 2 |
| cat | rat | 2 | yes | 1 | 3 | - | - | - |
If the name does no exist in df2 there should be a line or similar indicating that the name was not found.
Im not entirely sure how to get this work as I need to check for values from two columns and combine them into one data frame.
valuesinDf1bevolumeinstead ?