home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 1146877847

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/2028#issuecomment-1146877847 https://api.github.com/repos/pydata/xarray/issues/2028 1146877847 IC_kwDOAMm_X85EW_eX 5347026 2022-06-05T20:24:20Z 2022-06-05T20:24:20Z NONE

I agree this is harder that it should be.

Here's one way:

python In [28]: a.where(a.currency=='EUR', drop=True) Out[28]: <xarray.DataArray (country: 2)> array([20., 30.]) Coordinates: * country (country) <U7 'Germany' 'France' currency (country) <U3 'EUR' 'EUR'

I'm not sure whether .sel should work for non-IndexVariables - thoughts?

@max-sixty , perhaps there is any update on OPs question or maybe you can help to achieve the following? I would like sel based on a non-dim coordinate to be as fast as sel based on the dim itself. Timings: ```python

sel based on a non-dim coordinate

(using this coordinate directly .sel(product_id=26) would result in error "'no index found for coordinate product_id")

%timeit xds.sel(product=xds.product_id==26) 1.54 ms ± 64.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

sel based on the dim itself

%timeit xds.sel(product='GN91 Glove Medium') 499 µs ± 16.1 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

%timeit xds.where(xds.product_id==26, drop=True) 4.17 ms ± 39 µs per loop (mean ± std. dev. of 7 runs, 100 loops each) ``` Anyways, xarray is brilliant and made my week :)

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