home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 419714631

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/2399#issuecomment-419714631 https://api.github.com/repos/pydata/xarray/issues/2399 419714631 MDEyOklzc3VlQ29tbWVudDQxOTcxNDYzMQ== 514522 2018-09-09T13:04:12Z 2018-09-09T13:04:12Z CONTRIBUTOR

I see. Now I read about it, let me give another shot.

Let i be

<xarray.DataArray (y: 1, z: 1)> array([['a']], dtype='<U1') Dimensions without coordinates: y, z

and d be

<xarray.DataArray (x: 2)> array([0, 1]) Coordinates: * x (x) <U1 'a' 'a'

The result of d.loc[i] is equal to d.sel(x=i). Also, it seems reasonable to expect the its result should be the same as d0.sel(x=i) for d0 given by

<xarray.DataArray (x: 2, dim_1: 1)> array([[0], [1]]) Coordinates: * x (x) <U1 'a' 'a' Dimensions without coordinates: dim_1

as per column vector representation assumption.

Answer

Laying down the first dimension gives

| y | z | x | |---|---|---| | a | a | a | | | | a |

By order, x will match with y and therefore we will append a new dimension after x to match with z:

| y | z | x | dim_1 |---|---|---|-------| | a | a | a | ? | | | | a | ? |

where ? means any. Joining the first and second halves of the table gives

| y | z | x | dim_1 |---|---|---|-------| | a | a | a | ? | | a | a | a | ? |

And here is my suggestions. Use the mapping y|->x and z|->dim_1 to decide which axis to expand for the additional element. I will choose y-axis because the additional a was originally appended to the x-axis.

The answer is

<xarray.DataArray (y: 2, z: 1)> array([[0], [1]]) Coordinates: x (y, z) <U1 'a' 'a' Dimensions without coordinates: y, z

for

```

ans.coords["x"] <xarray.DataArray 'x' (y: 2, z: 1)> array([['a'], ['a']], dtype='<U1') Coordinates: x (y, z) <U1 'a' 'a' Dimensions without coordinates: y, z ```

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