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-1267830185,https://api.github.com/repos/pydata/xarray/issues/7108,1267830185,IC_kwDOAMm_X85LkY2p,90059220,2022-10-05T02:21:15Z,2022-10-05T02:21:15Z,NONE,"Thanks, it finally worked.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1391699976 https://github.com/pydata/xarray/issues/7108#issuecomment-1266073388,https://api.github.com/repos/pydata/xarray/issues/7108,1266073388,IC_kwDOAMm_X85Ldr8s,4160723,2022-10-03T21:28:43Z,2022-10-03T21:28:43Z,MEMBER,"> I suppose re-projecting it on a 0-360 would be the only way around this specific issue. A custom Xarray index would help, e.g., `PeriodicBoundaryIndex` (#7031) or a `GeographicIndex` leveraging libraries like S2Geometry or H3. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1391699976 https://github.com/pydata/xarray/issues/7108#issuecomment-1266030505,https://api.github.com/repos/pydata/xarray/issues/7108,1266030505,IC_kwDOAMm_X85Ldhep,90059220,2022-10-03T20:49:24Z,2022-10-03T20:49:24Z,NONE,"The values in `nc.lon` are technically ordered 'as they would be on a mercator projected map with origin at 0 N-0 E' considering I am dealing with data around 180 lon. Not that it would mater for pandas/xarray in that case. I suppose re-projecting it on a 0-360 would be the only way around this specific issue. And to answer earlier comments, `sub = nc_bug.sel(lon = 161.001, tolerance=.1)` raised the following: `KeyError: ""not all values found in index 'lon'. Try setting the `method` keyword argument (example: method='nearest').""` Which, when tried raised `ValueError: index must be monotonic increasing or decreasing`. It is indeed a problem with the order of the index. Thanks for your help and your time.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1391699976 https://github.com/pydata/xarray/issues/7108#issuecomment-1265012286,https://api.github.com/repos/pydata/xarray/issues/7108,1265012286,IC_kwDOAMm_X85LZo4-,4160723,2022-10-03T06:57:17Z,2022-10-03T06:57:17Z,MEMBER,"TBH, I had to do some research before figuring out what was going on :).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1391699976 https://github.com/pydata/xarray/issues/7108#issuecomment-1263807395,https://api.github.com/repos/pydata/xarray/issues/7108,1263807395,IC_kwDOAMm_X85LVCuj,5635139,2022-09-30T16:59:06Z,2022-09-30T16:59:06Z,MEMBER,"> Float indexes are often a source of pain, unfortunately! ...also for my ability to know what's going on, apparently :). Thanks a lot @benbovy . --- Yes, that would be great to raise a more informative error. We could also put an issue in upstream if pandas itself has the same issue.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1391699976 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)