Skip to content

Commit 08b1009

Browse files
authored
PERF: GroupBy.cumsum (#43309)
1 parent 9a81226 commit 08b1009

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pandas/core/internals/managers.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,13 @@ def get_numeric_data(self: T, copy: bool = False) -> T:
526526
copy : bool, default False
527527
Whether to copy the blocks
528528
"""
529-
return self._combine([b for b in self.blocks if b.is_numeric], copy)
529+
numeric_blocks = [blk for blk in self.blocks if blk.is_numeric]
530+
if len(numeric_blocks) == len(self.blocks):
531+
# Avoid somewhat expensive _combine
532+
if copy:
533+
return self.copy(deep=True)
534+
return self
535+
return self._combine(numeric_blocks, copy)
530536

531537
def _combine(
532538
self: T, blocks: list[Block], copy: bool = True, index: Index | None = None

0 commit comments

Comments
 (0)