Skip to content
forked from pydata/xarray

Commit f46f5d9

Browse files
committed
Remove a copy after stacking for a groupby.
Upstream bug pandas-dev/pandas#12813 is fixed
1 parent ba159bf commit f46f5d9

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

xarray/core/groupby.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,7 @@ def _ensure_1d(
241241
stacked_dim = "stacked_" + "_".join(map(str, orig_dims))
242242
# these dimensions get created by the stack operation
243243
inserted_dims = [dim for dim in group.dims if dim not in group.coords]
244-
# the copy is necessary here, otherwise read only array raises error
245-
# in pandas: https://github.com/pydata/pandas/issues/12813
246-
newgroup = group.stack({stacked_dim: orig_dims}).copy()
244+
newgroup = group.stack({stacked_dim: orig_dims})
247245
newobj = obj.stack({stacked_dim: orig_dims})
248246
return cast(T_Group, newgroup), newobj, stacked_dim, inserted_dims
249247

0 commit comments

Comments
 (0)