Skip to content

Commit 6e1514a

Browse files
Revert "REF: simplify _cython_agg_blocks (pandas-dev#35841)"
This reverts commit 0e199f3.
1 parent 098b970 commit 6e1514a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

pandas/core/groupby/generic.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,13 +1100,20 @@ def py_fallback(bvalues: ArrayLike) -> ArrayLike:
11001100
# in the operation. We un-split here.
11011101
result = result._consolidate()
11021102
assert isinstance(result, (Series, DataFrame)) # for mypy
1103-
mgr = result._mgr
1104-
assert isinstance(mgr, BlockManager)
1105-
assert len(mgr.blocks) == 1
11061103

11071104
# unwrap DataFrame to get array
1108-
result = mgr.blocks[0].values
1109-
return result
1105+
mgr = result._mgr
1106+
assert isinstance(mgr, BlockManager)
1107+
if len(mgr.blocks) != 1:
1108+
# We've split an object block! Everything we've assumed
1109+
# about a single block input returning a single block output
1110+
# is a lie. To keep the code-path for the typical non-split case
1111+
# clean, we choose to clean up this mess later on.
1112+
return mgr.as_array()
1113+
else:
1114+
assert len(mgr.blocks) == 1
1115+
result = mgr.blocks[0].values
1116+
return result
11101117

11111118
def blk_func(bvalues: ArrayLike) -> ArrayLike:
11121119

0 commit comments

Comments
 (0)