-1

I have 2 dataframes:

df1:

enter image description here

and df2:

enter image description here

They have differnet size. The common parts between these dataframes is the columns B (df1) and Z (df2), and based on columns B and Z I want to obtain new dataframe:

enter image description here

That add the major of student that are common between df1 and df2 and if it doesn't exist in df2 have empty value.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
h.b
  • 3
  • 2

1 Answers1

1

You can merge the two dataframes on the B and Z columns, e.g.:

df = pd.merge(left=df1, right=df2, left_on='B', right_on='Z', how='left')
Daniele Cappuccio
  • 1,952
  • 2
  • 16
  • 31