I have a few very large datasets with x, y and z values. These datasets represent interpolated height measurements in time. The first dataset (the original) contains the data for the entire area. In time parts of the area have been measured again. I want to overwrite the original dataset in the location where x and y are equal but z is different (the height has changed at location(x,y)).
So my dataframes look something like this
Original:
x y z
1 1 0.5
1 2 0.5
1 3 0.5
2 1 0.5
2 2 0.5
2 3 0.5
3 1 0.5
3 2 0.5
3 3 0.5
New measurement:
x y z
0 1 0.5
0 2 0.5
1 1 1.5
1 2 0.5
2 1 0.5
2 2 1.0
The final dataframe should look like this:
x y z
1 1 1.5
1 2 0.5
1 3 0.5
2 1 0.5
2 2 1.0
2 3 0.5
3 1 0.5
3 2 0.5
3 3 0.5
I can loop through all the measurements and see of the x and y occur in the original and if the z value is different (if so, replace it) but this takes forever and I can imagine that there must be a better way using pandas. How would I do this in a fast and efficient way?