Skip to content

Commit 6e1f697

Browse files
authored
REF: Skip all empty groups in _transform_general (#42404)
1 parent 8411993 commit 6e1f697

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/core/groupby/generic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,8 @@ def _transform_general(self, func, *args, **kwargs):
13091309
fast_path, slow_path = self._define_paths(func, *args, **kwargs)
13101310

13111311
for name, group in gen:
1312+
if group.size == 0:
1313+
continue
13121314
object.__setattr__(group, "name", name)
13131315

13141316
# Try slow path and fast path.
@@ -1325,9 +1327,7 @@ def _transform_general(self, func, *args, **kwargs):
13251327
# we need to broadcast across the
13261328
# other dimension; this will preserve dtypes
13271329
# GH14457
1328-
if not np.prod(group.shape):
1329-
continue
1330-
elif res.index.is_(obj.index):
1330+
if res.index.is_(obj.index):
13311331
r = concat([res] * len(group.columns), axis=1)
13321332
r.columns = group.columns
13331333
r.index = group.index

0 commit comments

Comments
 (0)