-2

I have two dataframes.

The first is (df1): enter image description here

The second is (df2):

enter image description here

My problem is to get the Internal Code - Variation from df1 in df2 by comparing VARIATION and MAIN PRODUCT CODE v2.

Example: In DF2: When MAIN PRODUCT CODE v2 is TN1050 and VARIATION is _1PCS then it needs to get "UTB1050_1PCS". Where DF2 takes reference from DF1.

My output should be like this in df2:

enter image description here

I really appreciate your help!! Thanks!

1 Answers1

1

Try something like this

df2 = df2.merge(df1, how="left", left_on=["VARIATION", "MAIN PRODUCT CODE v2"], right_on=["VARIATION", "MAIN PRODUCT CODE v2"])
Samir Hinojosa
  • 825
  • 7
  • 24