home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 334029215

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/1603#issuecomment-334029215 https://api.github.com/repos/pydata/xarray/issues/1603 334029215 MDEyOklzc3VlQ29tbWVudDMzNDAyOTIxNQ== 6815844 2017-10-04T01:55:02Z 2017-10-04T01:55:02Z MEMBER

I'm using MultiIndex a lot, but I noticed that it is just a workaround to index along multiple kinds of coordinate.

Consider the following example, ```python In [1]: import numpy as np ...: import xarray as xr ...: da = xr.DataArray(np.arange(5), dims=['x'], ...: coords={'experiment': ('x', [0, 0, 0, 1, 1]), ...: 'time': ('x', [0.0, 0.1, 0.2, 0.0, 0.15])}) ...:

In [2]: da Out[2]: <xarray.DataArray (x: 5)> array([0, 1, 2, 3, 4]) Coordinates: experiment (x) int64 0 0 0 1 1 time (x) float64 0.0 0.1 0.2 0.0 0.15 Dimensions without coordinates: x

```

I want to do something like this python da.sel(experiment=0).sel(time=0.1) but it cannot. MultiIndexing enables this,

python In [2]: da = da.set_index(exp_time=['experiment', 'time']) ...: da ...: Out[2]: <xarray.DataArray (x: 5)> array([0, 1, 2, 3, 4]) Coordinates: * exp_time (exp_time) MultiIndex - experiment (exp_time) int64 0 0 0 1 1 - time (exp_time) float64 0.0 0.1 0.2 0.0 0.15 Dimensions without coordinates: x

If we could make a selection from a non-index coordinate, MultiIndex is not necessary for this case.

I think there should be other important usecases of MultiIndex. I would be happy if anyone could list them in this issue.

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