Skip to content

Providing a fill value in merge() leads to a MergeError #5462

Answered by keewis
Ockenfuss asked this question in Q&A
Discussion options

You must be logged in to vote

Internally, merge will first align both objects and then "join" variables with the same name together using the method specified by compat. For the first call, that will be:

a: <xarray.Variable (x: 3)>
array([ 1.,  2., nan])
b: <xarray.Variable (x: 3)>
array([nan, nan,  3.])

while interpreting nan as missing. However, with the fill value, this becomes:

a: <xarray.Variable (x: 3)>
array([1., 2., 0.])
b: <xarray.Variable (x: 3)>
array([0., 0., 3.])

with this, the default compat method ("no_conflicts") will detect conflicting values for both arrays and thus raise.

You can get the second call to work by specifying a different compat method, e.g. "override", or by using a different function …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@TomNicholas
Comment options

@Ockenfuss
Comment options

Answer selected by max-sixty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants