I have a question regarding merging two rows of different dataframes in Python pandas.
Dataset A (imported as csv):
| Index | Parameter 1 | Parameter 2 | Parameter 3 | Parameter 4 |
|---|---|---|---|---|
| 1 | A10 | 1 | 4 | 8 |
| 2 | B06 | 5 | 5 | 5 |
| 3 | D04 | 6 | 3 | 4 |
Dataset 2 (imported as csv):
| Index | Parameter A | Parameter B | Parameter C | Parameter D |
|---|---|---|---|---|
| 1 | B06 | 0 | 2 | 5.5 |
| 2 | B06 | 2 | 4 | 4.5 |
| 3 | B06 | 4 | 6 | 7.4 |
| 4 | B06 | 6 | 8 | 8.8 |
I want the program to go through every row of Dataset A (with a for loop) and find the suitable row in Dataset B and merge them.
The suitable row in Dataset B is definde as
Parameter 1 = Parameter A
Parameter B < Parameter 2 <= Parameter C
The result should be look as:
| Index | Parameter 1/A | Parameter 2 | Parameter 3 | Parameter 4 | Parameter B | Parameter C | Parameter D |
|---|---|---|---|---|---|---|---|
| 1 | A10 | 1 | 4 | 8 | - | - | - |
| 2 | B06 | 5 | 5 | 5 | 4 | 6 | 7.4 |
| 3 | D04 | 6 | 3 | 4 | - | - | - |
Each row auf Dataset A has a suitable row in Dataset B.
I'm quite new in Python and ask politely for your help. Let me know, if you have some ideas, which can bring me further! Thank you so much!