new to python and can't seem to find the exact answer I am looking for though I believe there is an easier way to fill this info
I have df1 and df2
df1: FirstName LastName PhNo uniqueid
df2: uniqueid PhNo
I want to fill values missing in df1['PhNo'], with matching values in df2 based on matching uniqueid == uniqueid
Codes I used are as follows
dff = pd.merge(df1,df2,on = 'uniqueid', how = 'Left')
dff['PhNo'] = 0
dff['PhNo'][df1['PhNo_x'] >= 1] = df1['PhNo_x']
df1['PhNo'][df2['PhNo_y'] >= 1] = df1['PhNo_y']
this seems to do the work but does not seem like an efficient way of doing this. I am looking for a less number of lines and better technique than merge
df1
FirstName LastName PhNo uniqueid
Sam R 123x 1
John S 345x 2
Paul K np.Nan 3
Laney P no.NaN 4
df2
uniqueid PhNo
1 213x
3 675x
4 987x
desired output: df1
FirstName LastName PhNo uniqueid
Sam R 123x 1
John S 345x 2
Paul K **675x** 3
Laney P **987x** 4