0

Hello all I am trying to update my df1 with matching ids from df2. Hence the df1 datasets should not be increased or decreased inorder to maintain the row count respectively. .my df1 looks like

ID   Record Date    Gender  DOB Registration_Date
123  08-05-2012       NA    NA   NA
123  06-05-2013       NA    NA   NA
234  08-08-2011       NA    NA   NA
234  09-06-2012       NA    NA   NA
335  09-09-2001       NA    NA   NA
335  08-09-2002       NA    NA   NA
335  10-10-2003       NA    NA   NA
425  28-11-2004       NA    NA   NA
425  27-08-2006       NA    NA   NA

My df2 looks like

ID   Gender     DOB     Registration_Date
123    F    05-06-1990    28-08-2012
234    M    01-02-0991    05-06-2011
335    F    06-12-1996    07-08-2000
425    M    17-12-1999    09-07-2003

Expected Results :

ID  Record Date  Gender     DOB     Registration_Date
123 08-05-2012    F     05-06-1990   28-08-2012
123 06-05-2013    F     05-06-1990   28-08-2012
234 08-08-2011    M     01-02-0991   05-06-2011
234 09-06-2012    M     01-02-0991   05-06-2011
335 09-09-2001    F     06-12-1996   07-08-2000
335 08-09-2002    F     06-12-1996   07-08-2000
335 10-10-2003    F     06-12-1996   07-08-2000
425 28-11-2004    M     17-12-1999   09-07-2003
425 27-08-2006    M     17-12-1999   09-07-2003
Jammy
  • 33
  • 6
  • Did you try `merge(df1, df2, by = 'ID')` ? – Ronak Shah Sep 01 '20 at 09:05
  • @Ronak Shah Thanks but other than merge any other possibilities because it results in duplicate rows that are unidentified. kindly suggest better way. – Jammy Sep 01 '20 at 09:14
  • It doesn't result in duplicates for the example that you have shared. Can you update your post so that we can reproduce the issue that you are facing? – Ronak Shah Sep 01 '20 at 09:17

0 Answers0