home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 518674048

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/3176#issuecomment-518674048 https://api.github.com/repos/pydata/xarray/issues/3176 518674048 MDEyOklzc3VlQ29tbWVudDUxODY3NDA0OA== 5635139 2019-08-06T13:40:28Z 2019-08-06T13:40:28Z MEMBER

Thanks for the issue @gwgundersen

I think the docs are potentially a bit unclear, and maybe the error message. The existing intention of set_index is to set existing variables as indexes, rather than creating new ones. For example, to extend your case:

```python

In [16]: arr = xr.DataArray(data=np.ones((2, 3)), dims=['x', 'y'], coords={'x': range(2), 'y': range(3), 'a': ('x', [3,4])})

In [17]: arr Out[17]: <xarray.DataArray (x: 2, y: 3)> array([[1., 1., 1.], [1., 1., 1.]]) Coordinates: * x (x) int64 0 1 * y (y) int64 0 1 2 a (x) int64 3 4

In [18]: arr.set_index(x='a') Out[18]: <xarray.DataArray (x: 2, y: 3)> array([[1., 1., 1.], [1., 1., 1.]]) Coordinates: * x (x) int64 3 4 * y (y) int64 0 1 2 ```

We'd definitely be keen on a PR improving the error message (i.e. something like 'a' is not the name of an existing variable), and v open to feedback on the docs & the method's functionality; let us know if you'd be interested in that PR.

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