We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c604ee1 commit 321c560Copy full SHA for 321c560
xarray/core/groupby.py
@@ -866,7 +866,7 @@ def _combine(self, applied, shortcut=False):
866
if coord is not None and dim not in applied_example.dims:
867
index, index_vars = create_default_index_implicit(coord)
868
indexes = {k: index for k in index_vars}
869
- combined = combined._overwrite_indexes(indexes, coords=index_vars)
+ combined = combined._overwrite_indexes(indexes, index_vars)
870
combined = self._maybe_restore_empty_groups(combined)
871
combined = self._maybe_unstack(combined)
872
return combined
xarray/tests/test_groupby.py
@@ -936,9 +936,17 @@ def test_groupby_dataset_assign():
936
937
def test_groupby_dataset_map_dataarray_func():
938
# regression GH6379
939
- ds = xr.Dataset({"foo": ("x", [1, 2, 3, 4])}, coords={"x": [0, 0, 1, 1]})
+ ds = Dataset({"foo": ("x", [1, 2, 3, 4])}, coords={"x": [0, 0, 1, 1]})
940
actual = ds.groupby("x").map(lambda grp: grp.foo.mean())
941
- expected = xr.DataArray([1.5, 3.5], coords={"x": [0, 1]}, dims="x", name="foo")
+ expected = DataArray([1.5, 3.5], coords={"x": [0, 1]}, dims="x", name="foo")
942
+ assert_identical(actual, expected)
943
+
944
945
+def test_groupby_dataarray_map_dataset_func():
946
+ # regression GH6379
947
+ da = DataArray([1, 2, 3, 4], coords={"x": [0, 0, 1, 1]}, dims="x", name="foo")
948
+ actual = da.groupby("x").map(lambda grp: grp.mean().to_dataset())
949
+ expected = xr.Dataset({"foo": ("x", [1.5, 3.5])}, coords={"x": [0, 1]})
950
assert_identical(actual, expected)
951
952
0 commit comments