I have two DataFrames df_old and df_new with same columns x (=identifier or index) and y (=data).
Now I want to overwrite data in df_old which is available in df_new + add the data from df_new that is not in df_old, so basically an outer merge on x with overwrite of y.
I tried it with pandas.DataFrame.merge and pandas.DataFrame.update but I am not able to achieve the desired result in one line or without doing row wise computations.
Example:
x = np.array(range(0, 10))
y = np.array(range(0, 10))
df_old = pd.DataFrame(data={'x':x,'y':y})
x = np.array(range(5, 15))
y = np.array(range(0, 10))
df_new = pd.DataFrame(data={'x':x,'y':y})
x = np.array(range(0, 15))
y = np.append(np.array(range(0, 5)), np.array(range(0, 10)))
df_desired = pd.DataFrame(data={'x':x,'y':y})
EDIT: The focus of the solution should be on execution time and memory efficiency . Simple solutions e.g. a one-liner would be nice to have.