html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/3791#issuecomment-604580582,https://api.github.com/repos/pydata/xarray/issues/3791,604580582,MDEyOklzc3VlQ29tbWVudDYwNDU4MDU4Mg==,6130352,2020-03-26T17:51:34Z,2020-03-26T17:51:34Z,NONE,"That'll work, thanks @keewis!
fwiw the number of use cases I've found concerning my initial question, where there are repeated index values on both sides of the join, is way lower.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,569176457
https://github.com/pydata/xarray/issues/3791#issuecomment-604537050,https://api.github.com/repos/pydata/xarray/issues/3791,604537050,MDEyOklzc3VlQ29tbWVudDYwNDUzNzA1MA==,14808389,2020-03-26T16:39:38Z,2020-03-26T16:39:38Z,MEMBER,"The only way I could come up with is:
```python
In [2]: a = xr.DataArray(
...: name=""sample_id"",
...: data=[1, 2, 3],
...: dims=""population_name"",
...: coords={""population_name"": [""AFR"", ""EUR"", ""EUR""]},
...: )
...: b = xr.DataArray(
...: name=""population_size"",
...: data=[10, 100],
...: dims=""population_name"",
...: coords={""population_name"": [""AFR"", ""EUR""]},
...: )
...: a.to_dataset().assign({b.name: b.sel(population_name=a.population_name)})
Out[2]:
Dimensions: (population_name: 3)
Coordinates:
* population_name (population_name)
# array([1, 2, 3])
# Coordinates:
# * x (x) object 'AFR' 'EUR' 'EUR'
b = xr.DataArray(
data=[10, 100], dims='x',
coords=dict(pop_name=('x', ['AFR', 'EUR'])),
name='pop_size'
).set_index(dict(x='pop_name'))
#
# array([100, 10])
# Coordinates:
# * x (x) object 'EUR' 'AFR'
xr.merge([a, b])
# InvalidIndexError: Reindexing only valid with uniquely valued Index objects
```
The above does exactly what I want as long as the population names being used as the coordinate to merge on are unique, but that obviously doesn't make sense if those names correspond to a bunch of individuals in one of a small number of populations.
The larger context for this is that genetic data itself is typically some 2+ dimensional array with the first two dimensions corresponding to genomic sites and people. Xarray is perfect for carrying around the extra information relating to those dimensions as coordinates, but being able to attach new coordinate values by joins to external tables is important.
Am I missing something obvious in the API that will do this? Or am I likely better off converting DataArrays to DFs, doing my operations with some DF api, and then converting back?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,569176457
https://github.com/pydata/xarray/issues/3791#issuecomment-598800439,https://api.github.com/repos/pydata/xarray/issues/3791,598800439,MDEyOklzc3VlQ29tbWVudDU5ODgwMDQzOQ==,306380,2020-03-13T16:12:53Z,2020-03-13T16:12:53Z,MEMBER,"I wonder if there are multi-dimensional analogs that might be interesting.
@eric-czech , if you have time to say a bit more about the data and operation that you're trying to do I think it would be an interesting exercise to see how to do that operation with Xarray's current functionality. I wouldn't be surprised to learn that there was some way to do what you wanted that went under a different name here.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,569176457
https://github.com/pydata/xarray/issues/3791#issuecomment-595406486,https://api.github.com/repos/pydata/xarray/issues/3791,595406486,MDEyOklzc3VlQ29tbWVudDU5NTQwNjQ4Ng==,5635139,2020-03-05T19:32:38Z,2020-03-05T19:32:38Z,MEMBER,"Hi @eric-czech -- thanks for the issue.
Unfortunately xarray isn't strong as these sort of relational joins, and I don't think there's a way of doing that specific operation. Relational algebra generally depends on data on a single dimension, which fits into xarray's model less well.
Feel free to post back here with contiguous questions, though","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,569176457