diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index d0dad26cfb275..db6e2753ed698 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -330,7 +330,8 @@ def apply( if ignore_failures: return self._combine(result_blocks) - return type(self).from_blocks(result_blocks, self.axes) + out = type(self).from_blocks(result_blocks, self.axes) + return out def where(self: T, other, cond, align: bool, errors: str) -> T: if align: @@ -589,8 +590,14 @@ def copy_func(ax): new_axes = list(self.axes) res = self.apply("copy", deep=deep) + res.axes = new_axes + if self.ndim > 1: + # Avoid needing to re-compute these + res._blknos = self.blknos.copy() + res._blklocs = self.blklocs.copy() + if deep: res._consolidate_inplace() return res