id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 1128821318,PR_kwDOAMm_X84yULfs,6260,allow coordinates to be independent of `region` selection in to_zarr,43613877,open,0,,,2,2022-02-09T17:21:19Z,2023-10-24T23:37:21Z,,CONTRIBUTOR,,1,pydata/xarray/pulls/6260,"The ``region`` argument has been validated too strictly as coordinates needed to have a common dimension with the selected dimensions in ``region``. The validation is now restricted to data variables. - [X] Closes #6069 - [X] Tests added - [X] User visible changes (including notable bug fixes) are documented in `whats-new.rst` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6260/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 822320976,MDU6SXNzdWU4MjIzMjA5NzY=,4995,"KeyError when selecting ""nearest"" data with given tolerance ",43613877,open,0,,,8,2021-03-04T17:00:13Z,2022-10-25T14:35:35Z,,CONTRIBUTOR,,,," **What happened**: Selecting data with `ds.sel(index=given_index, method=""nearest"", tolerance=tolerance)` only works in case for each `given_index` exists an `index` that is within the given `tolerance`, otherwise a `KeyError: ""not all values found in index 'index'"" occurs. **What you expected to happen**: I would expect, that those indices that are not within the `tolerance` would simply be dropped. **Minimal Complete Verifiable Example**: ```python import xarray as xr ds = xr.DataArray([1,2,3,4,5], dims=[""lat""], coords={'lat':[10,20,30,50,60]}) # working example, all latitudes are within the tolerance ds.sel(lat=[5,15,40], method=""nearest"", tolerance=10) # #array([1, 2, 4]) #Coordinates: # * lat (lat) int64 10 20 50 # failing example, latitude 40 is not within the tolerance ds.sel(lat=[5,15,40], method=""nearest"", tolerance=5) # KeyError: ""not all values found in index 'lat'"" ``` I would expect ``` >>> ds.sel(lat=[5,15,40], method=""nearest"", tolerance=5) array([1, 2]) Coordinates: * lat (lat) int64 10 20 ``` **Anything else we need to know?**: **Environment**:
Output of xr.show_versions() INSTALLED VERSIONS ------------------ commit: 66acafa7f1f1477cfd6c5b7c3458859763433092 python: 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:12:38) [Clang 11.0.1 ] python-bits: 64 OS: Darwin OS-release: 20.2.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: None LOCALE: None.UTF-8 libhdf5: 1.10.6 libnetcdf: 4.7.4 xarray: 0.15.2.dev452+g66acafa7.d20210304 pandas: 1.2.3 numpy: 1.20.1 scipy: 1.6.0 netCDF4: 1.5.6 pydap: installed h5netcdf: 0.10.0 h5py: 3.1.0 Nio: None zarr: 2.6.1 cftime: 1.4.1 nc_time_axis: 1.2.0 PseudoNetCDF: installed rasterio: 1.2.0 cfgrib: 0.9.8.5 iris: 2.4.0 bottleneck: 1.3.2 dask: 2021.02.0 distributed: 2021.02.0 matplotlib: 3.3.4 cartopy: 0.18.0 seaborn: 0.11.1 numbagg: installed pint: 0.16.1 setuptools: 49.6.0.post20210108 pip: 20.2.4 conda: None pytest: 6.2.2 IPython: None sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4995/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 1362683132,I_kwDOAMm_X85ROOT8,6995,`mean` returns empty DataArray for `groupby_bins` containing `datetime64`,43613877,open,0,,,1,2022-09-06T04:20:40Z,2022-09-30T17:18:22Z,,CONTRIBUTOR,,,,"### What happened? Applying the `mean` operator to an xarray dataset that has been grouped by bins, removes variables containing values of type `datetime64`. ### What did you expect to happen? I expect that all variables are preserved after applying the `mean`-operator. For `min` and `max` this works as expected. `sum` is not meaningful, so it makes sense that the variable is dropped in that case as well. ### Minimal Complete Verifiable Example ```Python import numpy as np import pandas as pd import xarray as xr times = pd.date_range('2020-01-01', '2020-02-01', freq='1H') index = np.arange(len(times)) bins = np.arange(0,len(index),5) ds=xr.Dataset({'time':('index', times),'float':('index', np.linspace(0,1,len(index)))},coords={'index':index}) ds.groupby_bins('index', bins).mean() Dimensions: (index_bins: 148) Coordinates: * index_bins (index_bins) object (0, 5] (5, 10] ... (730, 735] (735, 740] Data variables: float (index_bins) float64 0.004032 0.01075 0.01747 ... 0.9852 0.9919 ds.groupby_bins('index', bins).min() Dimensions: (index_bins: 148) Coordinates: * index_bins (index_bins) object (0, 5] (5, 10] ... (730, 735] (735, 740] Data variables: time (index_bins) datetime64[ns] 2020-01-01T01:00:00 ... 2020-01-3... float (index_bins) float64 0.001344 0.008065 0.01478 ... 0.9825 0.9892 ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [X] Complete example — the example is self-contained, including all data and the text of any traceback. - [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [X] New issue — a search of GitHub Issues suggests this is not a duplicate. ### Relevant log output _No response_ ### Anything else we need to know? _No response_ ### Environment
INSTALLED VERSIONS ------------------ commit: None python: 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:43:44) [Clang 13.0.1 ] python-bits: 64 OS: Darwin OS-release: 21.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: None LOCALE: ('en_US', 'UTF-8') libhdf5: None libnetcdf: None xarray: 2022.6.0 pandas: 1.4.4 numpy: 1.23.2 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: 3.5.3 cartopy: None seaborn: None numbagg: None fsspec: 2022.8.2 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 65.3.0 pip: 22.2.2 conda: None pytest: None IPython: 8.4.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6995/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue