Skip to content

Commit

Permalink
Merge pull request #50 from fkroeber/fix
Browse files Browse the repository at this point in the history
fix: consistent dimensions for groupby outputs 🔧
  • Loading branch information
luukvdmeer authored Jul 1, 2024
2 parents cd4da2d + df3f979 commit ee59d61
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions semantique/processor/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def groupby(self, grouper, labels_as_names = True, **kwargs):
if is_list:
idx = pd.MultiIndex.from_arrays([x.data for x in grouper])
dim = grouper[0].dims
partition = list(obj.groupby(xr.IndexVariable(dim, idx)))
partition = list(obj.groupby(xr.IndexVariable(dim, idx), squeeze=False))
# Use value labels as group names if defined.
if labels_as_names:
labs = [x.sq.value_labels for x in grouper]
Expand All @@ -464,7 +464,7 @@ def groupby(self, grouper, labels_as_names = True, **kwargs):
else:
groups = [i[1].rename(i[0]) for i in partition]
else:
partition = list(obj.groupby(grouper[0]))
partition = list(obj.groupby(grouper[0], squeeze=False))
# Use value labels as group names if defined.
if labels_as_names:
labs = grouper[0].sq.value_labels
Expand Down Expand Up @@ -1605,7 +1605,7 @@ def _merge_dups(obj):
return Collection(dups).sq.merge(reducers.first_)
else:
return obj
groups = list(raw.groupby(dimension))
groups = list(raw.groupby(dimension, squeeze=False))
clean = xr.concat([_merge_dups(x[1]) for x in groups], dimension)
else:
clean = raw
Expand Down

0 comments on commit ee59d61

Please sign in to comment.