0

I would like to merge patient_df:

id    first_name      last_name      birthdate
1           John            Doe     2001-12-21
2          David          Xavier    1999-11-24

With this contact_df (based on columns {birthdate,first_name,last_name}):

first_name      last_name      birthdate      city      Postal   
     David          Xavier    1999-11-24   Buffalo      P9B3R3
      John            Doe     2001-12-21    Irvine      V4A3E2

Types of columns are all object, except id is int64

It returns empty when I tried this

df_merged = pd.merge(patient_df, contact_df, how='inner', on=['birthdate','first_name','last_name'])

The result is:

Empty DataFrame
Column: [id, first_name, last_name, birthdate, city, postal]
Index: []

Could you please help me?

tom
  • 33
  • 4

1 Answers1

1

To use merge correctly, you should try this line of code:

patient_df.merge(contact_df, how='inner', on=['birthdate','first_name','last_name'])

Hope it works correctly now!

Cheers, T

t.novaes
  • 126
  • 2