Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3506,6 +3506,8 @@ class animal locomotion
if axis == 1:
return self[key]

self._consolidate_inplace()

index = self.index
if isinstance(index, MultiIndex):
loc, new_index = self.index.get_loc_level(key, drop_level=drop_level)
Expand Down Expand Up @@ -5428,6 +5430,7 @@ def values(self) -> np.ndarray:
['lion', 80.5, 1],
['monkey', nan, None]], dtype=object)
"""
self._consolidate_inplace()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one has already been reverted (#34999)

return self._mgr.as_array(transpose=self._AXIS_REVERSED)

@property
Expand Down Expand Up @@ -6096,6 +6099,8 @@ def fillna(
inplace = validate_bool_kwarg(inplace, "inplace")
value, method = validate_fillna_kwargs(value, method)

self._consolidate_inplace()

# set the default here, so functions examining the signaure
# can detect if something was set (e.g. in groupby) (GH9221)
if axis is None:
Expand Down Expand Up @@ -6530,6 +6535,8 @@ def replace(
if not is_bool(regex) and to_replace is not None:
raise AssertionError("'to_replace' must be 'None' if 'regex' is not a bool")

self._consolidate_inplace()

if value is None:
# passing a single value that is scalar like
# when value is None (GH5319), for compat
Expand Down
8 changes: 8 additions & 0 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ def apply(self: T, f, align_keys=None, **kwargs) -> T:
result_blocks: List[Block] = []
# fillna: Series/DataFrame is responsible for making sure value is aligned

self._consolidate_inplace()

aligned_args = {k: kwargs[k] for k in align_keys}

for b in self.blocks:
Expand Down Expand Up @@ -410,6 +412,7 @@ def apply(self: T, f, align_keys=None, **kwargs) -> T:
def quantile(
self,
axis: int = 0,
consolidate: bool = True,
transposed: bool = False,
interpolation="linear",
qs=None,
Expand All @@ -423,6 +426,8 @@ def quantile(
Parameters
----------
axis: reduction axis, default 0
consolidate: bool, default True. Join together blocks having same
dtype
transposed: bool, default False
we are holding transposed data
interpolation : type of interpolation, default 'linear'
Expand All @@ -437,6 +442,9 @@ def quantile(
# simplify some of the code here and in the blocks
assert self.ndim >= 2

if consolidate:
self._consolidate_inplace()

def get_axe(block, qs, axes):
# Because Series dispatches to DataFrame, we will always have
# block.ndim == 2
Expand Down