1

I have two dataframes. The first dataframe looks like:

Name First_Score
tom  10
nick 15
juli 14
Luke 30

The second:

Name Second_Score
nick 7
tom  5
juli  1

I want to join these two dataframes so that I have

Name First_Score Second_Score
nick 10          7
tom  15          5
juli 14          1
Luke 30          NA

How can I do this?

data = [['tom', 10], ['nick', 15], ['juli', 14], ['Luke', 30]]


df1 = pd.DataFrame(data, columns = ['Name', 'First_Score'])

data2 = [['nick', 7], ['tom', 5], ['Ali', 1]]

df2 = pd.DataFrame(data2, columns = ['Name', 'Second_Score'])
Niam45
  • 552
  • 2
  • 16
  • Does this answer your question? [Pandas Merging 101](https://stackoverflow.com/questions/53645882/pandas-merging-101) – Alex Jan 04 '22 at 14:13
  • Does this answer your question? [how to do left join using pandas](https://stackoverflow.com/questions/32777922/how-to-do-left-join-using-pandas) – esqew Jan 04 '22 at 14:14

1 Answers1

3
df1.merge(df2, how='left', on='Name')
Sbunzini
  • 542
  • 2
  • 8