Skip to content

Joining on subset of coords #10434

Answered by dcherian
JulienBrn asked this question in Q&A
Jun 18, 2025 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Is this right? It's not broadcasted out like your expected_result though

import xarray.indexes

d1i = d1.set_xindex(("c1", "c2"), xr.indexes.PandasMultiIndex)
d2i = d2.set_xindex(("c1", "c2"), xr.indexes.PandasMultiIndex)

xr.merge([
    d1i, 
    # automatic alignment does not work because of the duplicated (c1, c2) = (0,0) in d1.
    # so we reindex manually
    d2i.reindex_like(d1i)
]).drop_indexes(("x", "c1", "c2"))

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@JulienBrn
Comment options

@dcherian
Comment options

@JulienBrn
Comment options

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