home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1263689036

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/7108#issuecomment-1263689036 https://api.github.com/repos/pydata/xarray/issues/7108 1263689036 IC_kwDOAMm_X85LUl1M 32801740 2022-09-30T15:01:42Z 2022-09-30T15:01:42Z CONTRIBUTOR

Pandas docs seem stricter than the implementation. From this snippet from pandas source code monotonicity is only required after get_loc fails.

My concern with checking first is that code like below will stop working (if I understand correctly). Is has unique but (alphabetically) unsorted coords (although its order may have meaning for the user). I regularly select a slice by specifying the labels corresponding to the first and last elements I want to extract.

I would suggest in this case to just try while catching any KeyError and raising with a nicer message instead of always checking first.

import xarray as xr da = xr.DataArray([0, 1, 2, 3], coords={'x': ['zero', 'one', 'two', 'three']}) da.sel(x=slice('zero', 'two')) Out[1]: <xarray.DataArray (x: 3)> array([0, 1, 2]) Coordinates: * x (x) <U5 'zero' 'one' 'two'

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