0

I have the two df as following:

Df 1:

Student ID    Idclass
  
  1,           1   
  2,           2   
  3,           1   
  4,           1   

Df 2:

IdClass         Class
  
  1,              A1
 
  2,              A2

Desired Output

StudentId       IdClass    Class

1,                 1,         A1

2,                 2,        A2

3,                 1,        A1

4,                 1,        A1

I think I should merge these df but Idk how.

kieunhi
  • 13
  • 2
  • looks like you need to merge on the numeric aspect of df2 - what issues have you had so far ? – Umar.H Oct 12 '20 at 13:54

1 Answers1

0

Like this:

new_df = df1.merge(df2, on=['IdClass'], how='left')
gtomer
  • 5,643
  • 1
  • 10
  • 21