I have three dataframes that together contain a complete dataset. I would like lookup values from the third dataframe in the second, and add this to the first.
So, in df2, when both AttributeID and AttributeNameID match in the same row in df3 i want to copy (AttributeText,AttributeNameText) from df3 and either replace (AttributeID,AttributeNameID) in df2 with (AttributeText,AttributeNameText) or make a new df with (AttributeText,AttributeNameText) and corresponing ProductID
df1: Contains product id and product name (+ many others)
ProdID | ProdName
001 | A fine shoe
002 | A warm hat
003 | A metal bar
df2: Contains which attributes each product have, one product can have several types of attributes and not just two as seen in this example.
ProdID | AttributeID | AttributeNameID
001 | 047 | 085
001 | 048 | 003
002 | 047 | 086
df3: Contains a lookuptable for the attributeID and the corresponding attributetext
AttributeID | AttributeText | AttributeNameID | AttributeNameText
047 | Color | 085 | Red
047 | Color | 086 | Blue
048 | Size | 003 | Small
Wanted Result:
ProdID | ProdName | Color | Size | Any other attribute that might exsist
001 | A fine shoe | Red | Small| xyz
002 | A warm hat | Blue | NULL | xyz
003 | A metal bar | NULL | NULL | xyz