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](https://github.com/pandas-dev/pandas/blob/87cfe4e38bafe7300a6003a1d18bd80f3f77c763/pandas/core/indexes/base.py#L6716-L6724) 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]: array([0, 1, 2]) Coordinates: * x (x)