I understand this seems like a very generic and duplicated question but I was unable to find the most relevant solution for my problem.
For example, I have below dataframe (df1):
receipt car parts
101 A oil
102 B tire
103 B oil
104 C glass
Another df2:
product name criteria
Valvoline oil winter
Valvoline oil performance
Valvoline oil regular
Goodyear tire regular
Goodyear tire performance
Bosch glass regular
expected dataframe is:
receipt car parts product
101 A oil Valvoline
102 B tire Goodyear
103 B oil Valvoline
104 C glass Bosch
I did try merge but the total length in df1 was changed.
data_copy = pd.merge(df1, df2, how= "left", left_on = 'parts', right_on = 'name' )
I was thinking to create a unique list from df2 and the join df1. But is there any other elegant way.
Thanks