home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 512031393

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/3126#issuecomment-512031393 https://api.github.com/repos/pydata/xarray/issues/3126 512031393 MDEyOklzc3VlQ29tbWVudDUxMjAzMTM5Mw== 2818208 2019-07-16T22:50:04Z 2019-07-16T22:50:04Z CONTRIBUTOR

Okay, a couple changes to the original PR: we now perform a shallow copy of the returned index in DataWithCoords.get_index and Indexes.__getitem__. The latter is needed because both Dataset.indexes and DataArray.indexes returns an Indexes object. Finally, I added a bunch of tests for various index accessors.

This seems pretty robust:

```python

import pandas as pd import xarray as xr index = pd.Index(list('abcd'), name='foo') series = pd.Series(range(4), index) array = xr.DataArray.from_series(series) array.get_index('foo').name = 'bar' array.get_index('foo').name 'foo' array['foo'].to_index().name = 'bar' array['foo'].to_index().name 'foo' array.to_index().name = 'bar' array.to_index().name 'foo' array.indexes['foo'].name = 'bar' array.indexes['foo'].name 'foo' ```

Since a Dataset is just a collection of DataArray objects, the behavior propagates nicely, e.g.

```python

dataset = xr.Dataset({'myvar': array}) dataset['myvar'].to_index().name = 'bar' dataset['myvar'].to_index().name 'foo' dataset.indexes['foo'].name = 'bar' dataset.indexes['foo'].name 'foo' ```

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