I have two dataframes such as:
dfa:
Name | ID | Amount
Bob V434 50.00
Jill B333 22.11
Hank B442 11.11
dfb:
Name | ID_First | ID_Second | ID_Third
Bob V434 E333 B442
Karen V434 E333 B442
Jill V434 E333 B442
Hank V434 E333 B442
I want to join dfa
to dfb
, but the ID
in dfa
only corresponds to one of the IDS in dfb
.
Is there a way I can join dfa
to dfb
for ID
in dfa
so basically if it matches any of the ids in dfb
then I can match amount from dfa
?
Required output would just be:
Name | ID_First | ID_Second | ID_Third | Amount
Bob V434 E333 B442 50.00
Jill V434 E333 B442 22.11
Hank V434 E333 B442 11.11
Basically join on Name that exists in both tables, but the ID
that exists in dfa
exists in dfb
under only one of the ID_First
, second or third columns so the amount that matches for the same name and same ID value but that ID value is only in one of the IDS
for dfb
.
Thanks