home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 507524966

This data as json

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
507524966 MDU6SXNzdWU1MDc1MjQ5NjY= 3404 groupby_bins raises ufunc 'isnan' error on 0.14.0 13837821 closed 0     1 2019-10-15T23:02:34Z 2019-10-17T21:13:45Z 2019-10-17T21:13:45Z CONTRIBUTOR      

I recently upgraded to xarray 0.14.0. When running code that used to work in 0.13, I get a TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'' in 0.14 when running code similar to the MCVE below. The code should return the GroupBy bins instead of the error.

MCVE Code Sample

```python import xarray as xr import pandas as pd import numpy as np

ts = pd.date_range(start='2010-08-01', end='2010-08-15', freq='24.8H')

ds = xr.Dataset() ds['time'] = xr.DataArray(pd.date_range('2010-08-01', '2010-08-15', freq='15min'), dims='time') ds['val'] = xr.DataArray(np.random.rand(*ds['time'].shape), dims='time')

ds.groupby_bins('time', ts) #error thrown here ```

Full error details below.

--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-35-43742bae2c94> in <module> 9 ds['val'] = xr.DataArray(np.random.rand(*ds['time'].shape), dims='time') 10 ---> 11 ds.groupby_bins('time', ts) ~/miniconda3/lib/python3.7/site-packages/xarray/core/common.py in groupby_bins(self, group, bins, right, labels, precision, include_lowest, squeeze, restore_coord_dims) 727 "labels": labels, 728 "precision": precision, --> 729 "include_lowest": include_lowest, 730 }, 731 ) ~/miniconda3/lib/python3.7/site-packages/xarray/core/groupby.py in __init__(self, obj, group, squeeze, grouper, bins, restore_coord_dims, cut_kwargs) 322 323 if bins is not None: --> 324 if np.isnan(bins).all(): 325 raise ValueError("All bin edges are NaN.") 326 binned = pd.cut(group.values, bins, **cut_kwargs) TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None libhdf5: 1.10.4 libnetcdf: 4.6.2 xarray: 0.14.0 pandas: 0.25.1 numpy: 1.17.2 scipy: 1.3.0 netCDF4: 1.5.1.2 pydap: installed h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2.2.0 distributed: 2.5.2 matplotlib: 3.1.1 cartopy: 0.17.0 seaborn: 0.9.0 numbagg: None setuptools: 41.4.0 pip: 19.3 conda: 4.7.12 pytest: 5.1.1 IPython: 7.8.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3404/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 5.017ms · About: xarray-datasette