I am trying to concatenate two dataframes together which expectedly results in NaN values being created for columns X and Y.
d1 = {'Name':['X1','X2','X3','X4','X5'],
'Value':[1,2,3,4,5],
'X':[10,10,20,20,30],
'Y':[10,20,10,20,10]}
df1 = pd.DataFrame(d1)
d2 = {'Name':['X1','X2','X2','X3'],
'Value':[8,6,5,12]}
df2 = pd.DataFrame(d2)
df1.append(df2).reset_index(drop=True)
I would like to update the NaN values in cols X and Y with the corresponding values already populated in df1.
For example any instance of a row containing df1['Name'] == 'X1' would have the same df1['X'] and df1['Y'] values as those associated with df1['Name'] == 'X1'.
In this example the values would be: Name = X1, X = 10, Y = 10.
Many thanks for the help.