home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 226003087

This data as json

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/742#issuecomment-226003087 https://api.github.com/repos/pydata/xarray/issues/742 226003087 MDEyOklzc3VlQ29tbWVudDIyNjAwMzA4Nw== 4304478 2016-06-14T20:18:11Z 2016-06-14T20:18:11Z NONE

I'm having a similar issue, expanding the complexity in that I want to concatenate across multiple dimensions. I'm not sure if that's a cogent way to explain it, but here's an example. I have:

python m = xr.DataArray(data=[[[1.1, 1.2, 1.3]]], coords={'Dim1': ['A', 'B', 'C'], 'Dim2':['D'], 'Dim3':['F']}) n = xr.DataArray(data=[[[2.1, 2.2, 2.3]]], coords={'Dim1': ['A', 'B', 'C'], 'Dim2':['E'], 'Dim3':['F']}) o = xr.DataArray(data=[[[3.1, 3.2, 3.3]]], coords={'Dim1': ['A', 'B', 'C'], 'Dim2':['D'], 'Dim3':['G']}) p = xr.DataArray(data=[[[4.1, 4.2, 4.3]]], coords={'Dim1': ['A', 'B', 'C'], 'Dim2':['E'], 'Dim3':['G']})

Which I want to merge into a single, fully populated array similar to what I'd get if I did:

``` python data =[[[ 1.1, 1.2, 1.3], [ 3.1, 3.2, 3.3]],

   [[ 2.1,  2.2,  2.3],
    [ 4.1,  4.2,  4.3]]]

xr.DataArray(data=data, coords={'Dim1': ['A', 'B', 'C'], 'Dim2':['D', 'E'], 'Dim3':['F', 'G']}) ```

i.e.

``` python <xarray.DataArray (Dim2: 2, Dim3: 2, Dim1: 3)> array([[[ 1.1, 1.2, 1.3], [ 3.1, 3.2, 3.3]],

   [[ 2.1,  2.2,  2.3],
    [ 4.1,  4.2,  4.3]]])

Coordinates: * Dim2 (Dim2) |S1 'D' 'E' * Dim3 (Dim3) |S1 'F' 'G' * Dim1 (Dim1) |S1 'A' 'B' 'C' ```

@jcmgray's function is pretty close, although the array indicies are described slightly differently (I'm not sure if this is a big deal or not...). Note the 'object' type for Dim2 and Dim3:

``` python <xarray.DataArray (Dim2: 2, Dim3: 2, Dim1: 3)> array([[[ 1.1, 1.2, 1.3], [ 3.1, 3.2, 3.3]],

   [[ 2.1,  2.2,  2.3],
    [ 4.1,  4.2,  4.3]]])

Coordinates: * Dim2 (Dim2) object 'D' 'E' * Dim3 (Dim3) object 'F' 'G' * Dim1 (Dim1) |S1 'A' 'B' 'C' ```

It would be great to have a canonical way to do this. What should I try?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  130753818
Powered by Datasette · Queries took 0.617ms · About: xarray-datasette