Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def __init__(
full_index = None

if bins is not None:
if np.isnan(bins).all():
if duck_array_ops.isnull(bins).all():
raise ValueError("All bin edges are NaN.")
binned = pd.cut(group.values, bins, **cut_kwargs)
new_dim_name = group.name + "_bins"
Expand Down
11 changes: 11 additions & 0 deletions xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,15 @@ def test_groupby_grouping_errors():
dataset.to_array().groupby(dataset.foo * np.nan)


def test_groupby_bins_timeseries():
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", pd.date_range(start="2010-08-01", end="2010-08-15", freq="24.8H")
)


# TODO: move other groupby tests from test_dataset and test_dataarray over here