Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -9810,8 +9810,12 @@ def _reduce(
FutureWarning,
stacklevel=5,
)
cols = self.columns[~dtype_is_dt]
self = self[cols]
# Non-copy equivalent to
# cols = self.columns[~dtype_is_dt]
# self = self[cols]
predicate = lambda x: not is_datetime64_any_dtype(x.dtype)
mgr = self._mgr._get_data_subset(predicate)
self = type(self)(mgr)

# TODO: Make other agg func handle axis=None properly GH#21597
axis = self._get_axis_number(axis)
Expand Down
4 changes: 4 additions & 0 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ def is_view(self) -> bool:

return False

def _get_data_subset(self: T, predicate: Callable) -> T:
blocks = [blk for blk in self.blocks if predicate(blk.values)]
return self._combine(blocks, copy=False)

def get_bool_data(self: T, copy: bool = False) -> T:
"""
Select blocks that are bool-dtype and columns from object-dtype blocks
Expand Down