home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1259346181

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/5874#issuecomment-1259346181 https://api.github.com/repos/pydata/xarray/issues/5874 1259346181 IC_kwDOAMm_X85LEBkF 4160723 2022-09-27T11:11:07Z 2022-09-27T11:11:07Z MEMBER

The desired behavior is the possibility to set x_str as an index without changing its name.

This will be enabled by #6971, hopefully merged before the next release:

```python arr = arr.set_xindex("x_str").set_xindex("x_num")

arr

<xarray.DataArray (t: 4, x: 4)>

array([[ 0, 1, 2, 3],

[ 4, 5, 6, 7],

[ 8, 9, 10, 11],

[12, 13, 14, 15]])

Coordinates:

* x_str (x) <U1 'a' 'b' 'c' 'd'

* x_num (x) int64 1 2 3 4

Dimensions without coordinates: t, x

arr.sel(x_str="a")

<xarray.DataArray (t: 4)>

array([ 0, 4, 8, 12])

Coordinates:

x_str <U1 'a'

x_num int64 1

Dimensions without coordinates: t

arr.sel(x_num=1)

<xarray.DataArray (t: 4)>

array([ 0, 4, 8, 12])

Coordinates:

x_str <U1 'a'

x_num int64 1

Dimensions without coordinates: t

```

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