-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Merging variables with overlapping not but not conflicting values #835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm currently in the process of refactoring the merge code so this should be pretty easy to add in. A few snippets that should come in handy: def combine_first(arrays):
notnulls = [ops.notnull(array) for array in arrays]
first_notnull = ops.argmax(ops.stack(notnulls), axis=0)
return ops.choose(first_notnull, arrays)
def combine_if_equal(arrays):
combined = combine_first(arrays)
combined_null = ops.isnull(combined)
if not all(((combined == array) | combined_null).all() for array in arrays):
raise ValueError
return combined |
Actually, we can just write:
|
Fixed by #1204 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It should be possible to safely merge together variables with values
[NaN, 1, 2]
and[0, 1, NaN]
by using methods such ascombine_first
(which should also be OK with conflicting values, like the pandas method) andmerge
(which should raise if values conflict).See this stackoverflow post for a merge example: http://stackoverflow.com/questions/36731870/how-to-merge-xarray-datasets-with-conflicting-coordinates
The text was updated successfully, but these errors were encountered: