Skip to content

Commit b5b466e

Browse files
Revert "CLN: _consolidate_inplace less (#34389)"
This reverts commit 760ba37.
1 parent 707640c commit b5b466e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pandas/core/generic.py

+9
Original file line numberDiff line numberDiff line change
@@ -3369,6 +3369,8 @@ class max_speed
33693369

33703370
nv.validate_take(tuple(), kwargs)
33713371

3372+
self._consolidate_inplace()
3373+
33723374
new_data = self._mgr.take(
33733375
indices, axis=self._get_block_manager_axis(axis), verify=True
33743376
)
@@ -3506,6 +3508,8 @@ class animal locomotion
35063508
if axis == 1:
35073509
return self[key]
35083510

3511+
self._consolidate_inplace()
3512+
35093513
index = self.index
35103514
if isinstance(index, MultiIndex):
35113515
loc, new_index = self.index.get_loc_level(key, drop_level=drop_level)
@@ -5428,6 +5432,7 @@ def values(self) -> np.ndarray:
54285432
['lion', 80.5, 1],
54295433
['monkey', nan, None]], dtype=object)
54305434
"""
5435+
self._consolidate_inplace()
54315436
return self._mgr.as_array(transpose=self._AXIS_REVERSED)
54325437

54335438
@property
@@ -6096,6 +6101,8 @@ def fillna(
60966101
inplace = validate_bool_kwarg(inplace, "inplace")
60976102
value, method = validate_fillna_kwargs(value, method)
60986103

6104+
self._consolidate_inplace()
6105+
60996106
# set the default here, so functions examining the signaure
61006107
# can detect if something was set (e.g. in groupby) (GH9221)
61016108
if axis is None:
@@ -6530,6 +6537,8 @@ def replace(
65306537
if not is_bool(regex) and to_replace is not None:
65316538
raise AssertionError("'to_replace' must be 'None' if 'regex' is not a bool")
65326539

6540+
self._consolidate_inplace()
6541+
65336542
if value is None:
65346543
# passing a single value that is scalar like
65356544
# when value is None (GH5319), for compat

pandas/core/internals/managers.py

+10
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ def apply(self: T, f, align_keys=None, **kwargs) -> T:
378378
result_blocks: List[Block] = []
379379
# fillna: Series/DataFrame is responsible for making sure value is aligned
380380

381+
self._consolidate_inplace()
382+
381383
aligned_args = {k: kwargs[k] for k in align_keys}
382384

383385
for b in self.blocks:
@@ -410,6 +412,7 @@ def apply(self: T, f, align_keys=None, **kwargs) -> T:
410412
def quantile(
411413
self,
412414
axis: int = 0,
415+
consolidate: bool = True,
413416
transposed: bool = False,
414417
interpolation="linear",
415418
qs=None,
@@ -423,6 +426,8 @@ def quantile(
423426
Parameters
424427
----------
425428
axis: reduction axis, default 0
429+
consolidate: bool, default True. Join together blocks having same
430+
dtype
426431
transposed: bool, default False
427432
we are holding transposed data
428433
interpolation : type of interpolation, default 'linear'
@@ -437,6 +442,9 @@ def quantile(
437442
# simplify some of the code here and in the blocks
438443
assert self.ndim >= 2
439444

445+
if consolidate:
446+
self._consolidate_inplace()
447+
440448
def get_axe(block, qs, axes):
441449
# Because Series dispatches to DataFrame, we will always have
442450
# block.ndim == 2
@@ -667,6 +675,8 @@ def is_mixed_type(self) -> bool:
667675

668676
@property
669677
def is_numeric_mixed_type(self) -> bool:
678+
# Warning, consolidation needs to get checked upstairs
679+
self._consolidate_inplace()
670680
return all(block.is_numeric for block in self.blocks)
671681

672682
@property

0 commit comments

Comments
 (0)