I have a dataframe with this info let call it df1:
Patient Id Email5628 mapy@gmail.com17433 ssdx@gmail.com861415336 cris@yahoo.es17604 avasallo@yahoo.com8635 carolinavi@gmail.com1542415393 TAM20@YAHOO.COM
also have df2 which is bigger but for sure it have the patient id but It may have a different email or even dont have it at all. so what I want to do is replace the email in df1 with the one in df2 where the patient ids match and if the df2 email is not empty.
so I have tried with this:
df1['Email'] = df1['Patient Id'].map(df2.set_index('patient_id')['email_address'])
it locate correctly the match of the patient ids and replace the email but it replace it even when df2 email is empty ending up like this:
Patient Id Email email nuevo5628 mapy@gmail.com mapy@gmail.com17433 ssdx@gmail.com ssdx002gmail.com8614 15336 cris@yahoo.es 17604 avasallo@yahoo.com avasallo@yahoo.com8635 carolinavi@gmail.com carolinavictoria.md@gmail.com15424 15393 TAM20@YAHOO.COM TACM2010@YAHOO.COM
as you can see, it the email ssdx@gmail.com and TAM20@YAHOO.com but also overwrite cris@yahoo.es with an empty cell that's what i want to avoid.
any help is appreciated, thank you!