You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If however the last bin includes the value 1 it runs as expected:
# If I include a larger value at the end it works
bins = np.array([0, 20, 40, 60 , 80, 100, 1e7])*1e-6
binned = data.groupby_bins(data, bins).sum()
binned
Is this expected behaviour? I would prefer it if it returned nan values for the bins that capture no values.
It took me a bit to find out why my script using this was failing, and if this is expected behavior could a more helpful error message be considered?
Expected Output
Output of xr.show_versions()
# Paste the output here xr.show_versions() here
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
I agree, this behavior is not so useful. It appears that our current groupby_bins logic fails with an error if none of the data falls in the bins.
I'll mark this as a bug. It could be a little tricky to fix because our current logic in GroupBy.apply() (used by .sum() indirectly) looks at one result to figure out how to stack grouped results. But at the very least we should raise a more helpful error message.
Consider the following example.
If however the last bin includes the value 1 it runs as expected:
Problem description
Is this expected behaviour? I would prefer it if it returned nan values for the bins that capture no values.
It took me a bit to find out why my script using this was failing, and if this is expected behavior could a more helpful error message be considered?
Expected Output
Output of
xr.show_versions()
xarray: 0.10.0rc1-9-gdbf7b01
pandas: 0.20.3
numpy: 1.13.1
scipy: 0.19.1
netCDF4: 1.2.9
h5netcdf: 0.4.1
Nio: None
bottleneck: 1.2.1
cyordereddict: None
dask: 0.15.4
matplotlib: 2.0.2
cartopy: 0.15.1
seaborn: 0.8.1
setuptools: 36.3.0
pip: 9.0.1
conda: None
pytest: 3.2.2
IPython: 6.1.0
sphinx: 1.6.5
The text was updated successfully, but these errors were encountered: