home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 224092354

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/pull/802#issuecomment-224092354 https://api.github.com/repos/pydata/xarray/issues/802 224092354 MDEyOklzc3VlQ29tbWVudDIyNDA5MjM1NA== 4160723 2016-06-06T21:21:29Z 2016-06-06T21:21:29Z MEMBER

```

index = pd.MultiIndex.from_product((list('abc'), range(3))) index.names = ('one', 'two') data = xr.DataArray(range(9), [('x', index)]) data <xarray.DataArray (x: 9)> array([0, 1, 2, 3, 4, 5, 6, 7, 8]) Coordinates: * x (x) object ('a', 0) ('a', 1) ('a', 2) ('b', 0) ('b', 1) ... ```

Example using a tuple of scalar/tuple/list/slice labels for each level:

```

data.sel(x=('a', (0, 1))) <xarray.DataArray (x: 2)> array([0, 1]) Coordinates: * x (x) object ('a', 0) ('a', 1) ```

Example using a list of several combinations of multi-index labels:

```

data.sel(x=[('a', 0), ('b', 1), ('c', 1)]) <xarray.DataArray (x: 3)> array([0, 4, 7]) Coordinates: * x (x) object ('a', 0) ('b', 1) ('c', 1) ```

All the following examples raise an error:

```

data.sel(x=(('a', 0), ('b', 1), ('c', 1))) data.sel(x=['a', (0, 1)]) data.sel(x=[['a', 0], ['b', 1], ['c', 1]]) ```

Note that after verification, pandas has the same behavior for all of the examples shown here.

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