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/3946#issuecomment-610522710,https://api.github.com/repos/pydata/xarray/issues/3946,610522710,MDEyOklzc3VlQ29tbWVudDYxMDUyMjcxMA==,35968931,2020-04-07T17:35:12Z,2020-04-07T17:35:12Z,MEMBER,If people think this would be useful addition to the API then we could add it - or it could just be a cookbook recipe.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283 https://github.com/pydata/xarray/issues/3946#issuecomment-610519628,https://api.github.com/repos/pydata/xarray/issues/3946,610519628,MDEyOklzc3VlQ29tbWVudDYxMDUxOTYyOA==,35968931,2020-04-07T17:29:10Z,2020-04-07T17:32:59Z,MEMBER,"Hi @lanougue , thanks for the suggestion! If I understand correctly, you want to check that all elements are close along one dimension, and if so, then select only one index from that dimension? That seems to me to be two consecutive operations, the first of which is a reduction, and the second is just `.isel`: ```python da = xr.DataArray([[1.,2.],[1.,2.]], dims=('x','y')) def reduce_if_constant_along_dim(da, dim): first = da.isel(**{dim: 0}) constant_along_dim = (da == first).all(dim) true = xr.full_like(da, fill_value=True).isel(**{dim: 0}, drop=True) if constant_along_dim.equals(true): return da.isel(**{dim: 0}, drop=True) else: return da print(reduce_if_constant_along_dim(da, dim='x')) ``` ```bash array([1., 2.]) ``` or are you imagining something that applies the above function to every dim, more like: ```python def drop_constant_dims(da): for dim in da.dims: da = reduce_if_constant_along_dim(da, dim) return da print(drop_constant_dims(da)) ``` ```bash array([1., 2.]) ``` There might be a slightly neater way using `reduce` somehow though.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283 https://github.com/pydata/xarray/issues/3946#issuecomment-610520813,https://api.github.com/repos/pydata/xarray/issues/3946,610520813,MDEyOklzc3VlQ29tbWVudDYxMDUyMDgxMw==,35968931,2020-04-07T17:31:28Z,2020-04-07T17:31:28Z,MEMBER,@jthielen you should be able to adapt my example to check for being within a tolerance rather than strict equality.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,595813283