Skip to content

Commit 3543449

Browse files
committed
BUG: Fix groupby bug pandas-dev#21624.
Fixes bug where operations such as transform('sum') raise errors when only a single null group exists.
1 parent 1dd05cc commit 3543449

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/core/groupby/groupby.py

+4
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,10 @@ def size(self):
23502350
out = np.bincount(ids[ids != -1], minlength=ngroup)
23512351
else:
23522352
out = ids
2353+
# Covers the edge case where only a null group exists
2354+
if self.result_index.shape[0] == 0:
2355+
out = []
2356+
23532357
return Series(out,
23542358
index=self.result_index,
23552359
dtype='int64')

0 commit comments

Comments
 (0)