I have a dataframe with many rows that have to be matched by various conditions. So far I am struggling with that and slowly losing hope that I'll ever be able to solve it. Here is an example of my dataframe:
No Test Reference Value
5 OF 3 55
7 EPM 1 33
5 H1 - 23
7 H3 - 22
5 R1 - 15
7 R3 - 28
5 H3 - 60
7 H1 - 33
5 R3 - 21
7 R1 - 18
5 T - 20
7 T - 17
My goal is to get the dataframe with "Test" (OF or EPM) values matched with other values (from different rows) in new columns (H, R, and T). Matched data have to be selected based on the condition in "No" and "Reference" columns. Values (1 or 3) of "Reference" column refer to row ("Test" column: 1 = H1 and R1, 3 = H3 and R3). Row with T in the "Test" column is matched only based on the value in "No" column. Here is an example result:
No Test Reference Value H R T
5 OF 3 55 60 21 20
7 EPM 1 33 33 18 17
I appreciated any help you can provide. Thank you so much!!!