Try this:
df2 = df2.replace(r'^\s*$', np.nan, regex=True)df2 = df2.set_index("patient_id")['email_address'].fillna(df1.set_index('Patient Id')['Email']).reset_index()df1['Email'] = df1['Patient Id'].map(df2.set_index('patient_id')['email_address'])
The first line replaces empty strings with NaN. The second line fills the Nan values in df2 with values from df1. The last line is the same as the line you had.