Closed
Description
Code Sample
arr = xr.DataArray(
np.ones(3),
dims=('x',),
coords={
'x': ('x', np.array([1, 3, 6])),
}
)
list(arr.groupby('x'))
[(1, <xarray.DataArray ()>
array(1.)
Coordinates:
x int64 1),
(3, <xarray.DataArray ()>
array(1.)
Coordinates:
x int64 3),
(6, <xarray.DataArray ()>
array(1.)
Coordinates:
x int64 6)]
Problem description
The dimension x disappear. I have done some tests and it seems that this problem raise only with strictly ascending coordinates.
For example in this case it works correctly:
arr = xr.DataArray(
np.ones(3),
dims=('x',),
coords={
'x': ('x', np.array([2, 1, 0])),
}
)
list(arr.groupby('x'))
[(0, <xarray.DataArray (x: 1)>
array([1.])
Coordinates:
* x (x) int64 0),
(1, <xarray.DataArray (x: 1)>
array([1.])
Coordinates:
* x (x) int64 1),
(2, <xarray.DataArray (x: 1)>
array([1.])
Coordinates:
* x (x) int64 2)]
Expected Output
arr = xr.DataArray(
np.ones(3),
dims=('x',),
coords={
'x': ('x', np.array([1, 3, 6])),
}
)
list(arr.groupby('x'))
[(1, <xarray.DataArray (x: 1)>
ar1ay([1.])
Coordinates:
* x (x) int64 1),
(3, <xarray.DataArray (x: 1)>
array([1.])
Coordinates:
* x (x) int64 3),
(6, <xarray.DataArray (x: 1)>
array([1.])
Coordinates:
* x (x) int64 6)]
Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.0.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-41-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
xarray: 0.10.4
pandas: 0.22.0
numpy: 1.14.3
scipy: 1.1.0
netCDF4: 1.3.1
h5netcdf: None
h5py: 2.7.1
Nio: None
zarr: None
bottleneck: None
cyordereddict: None
dask: 0.17.4
distributed: 1.21.8
matplotlib: 2.2.2
cartopy: 0.16.0
seaborn: None
setuptools: 38.4.1
pip: 10.0.1
conda: None
pytest: 3.5.1
IPython: 6.2.1
sphinx: 1.7.4