home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 803491262

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/4892#issuecomment-803491262 https://api.github.com/repos/pydata/xarray/issues/4892 803491262 MDEyOklzc3VlQ29tbWVudDgwMzQ5MTI2Mg== 5635139 2021-03-21T00:35:57Z 2021-03-21T00:35:57Z MEMBER

It's a good issue!

I would have thought .sel should default to using labels. I recognize that boolean indexing is really helpful — and think we should try and support it more (e.g. https://github.com/pydata/xarray/issues/1887).

And I recognize .sel delegates to .isel in some cases — e.g. where there are no indexes on a dimension.

But here, I propose we prioritize the labels above the boolean indexing in .sel. People can still use .isel if they want bool indexing in the method call syntax:

```python

In [4]: test = xr.DataArray( ...: np.ones((3,2)), ...: dims=["ternary","binary"], ...: coords={"ternary":[3,7,9],"binary":[False,True]} ...: )

In [5]: test.sel(binary=[True,False]) Out[5]: <xarray.DataArray (ternary: 3, binary: 1)> array([[1.], [1.], [1.]]) Coordinates: * ternary (ternary) int64 3 7 9 * binary (binary) bool False

In [6]: test.isel(binary=[True,False]) Out[6]: <xarray.DataArray (ternary: 3, binary: 1)> array([[1.], [1.], [1.]]) Coordinates: * ternary (ternary) int64 3 7 9 * binary (binary) bool False ```

I would also be OK removing the .sel delegation to .isel if it causes complications. IIUC the main use case is a single method call to index labels and dimensions without labels. But that's easy to replace with two method calls, I think?

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