Skip to content

Commit 681cf74

Browse files
authored
Propagate attrs better (#124)
1 parent 8039059 commit 681cf74

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

flox/xarray.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def wrapper(array, *by, func, skipna, **kwargs):
366366
if all(d not in ds[var].dims for d in dim):
367367
actual[var] = ds[var]
368368

369-
for name, expect in zip(group_names, expected_groups):
369+
for name, expect, by_ in zip(group_names, expected_groups, by):
370370
# Can't remove this till xarray handles IntervalIndex
371371
if isinstance(expect, pd.IntervalIndex):
372372
expect = expect.to_numpy()
@@ -382,6 +382,8 @@ def wrapper(array, *by, func, skipna, **kwargs):
382382
actual = actual.set_coords(levelnames)
383383
else:
384384
actual[name] = expect
385+
if keep_attrs:
386+
actual[name].attrs = by_.attrs
385387

386388
if unindexed_dims:
387389
actual = actual.drop_vars(unindexed_dims)

0 commit comments

Comments
 (0)