Skip to content

Commit dccbd4a

Browse files
jbrockmendelpull[bot]
authored andcommitted
CLN: remove inplace kwarg from NDFrame._consolidate (#36906)
1 parent 80458c7 commit dccbd4a

File tree

4 files changed

+6
-18
lines changed

4 files changed

+6
-18
lines changed

pandas/core/generic.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -5451,27 +5451,18 @@ def f():
54515451

54525452
self._protect_consolidate(f)
54535453

5454-
def _consolidate(self, inplace: bool_t = False):
5454+
def _consolidate(self):
54555455
"""
54565456
Compute NDFrame with "consolidated" internals (data of each dtype
54575457
grouped together in a single ndarray).
54585458
5459-
Parameters
5460-
----------
5461-
inplace : bool, default False
5462-
If False return new object, otherwise modify existing object.
5463-
54645459
Returns
54655460
-------
54665461
consolidated : same type as caller
54675462
"""
5468-
inplace = validate_bool_kwarg(inplace, "inplace")
5469-
if inplace:
5470-
self._consolidate_inplace()
5471-
else:
5472-
f = lambda: self._mgr.consolidate()
5473-
cons_data = self._protect_consolidate(f)
5474-
return self._constructor(cons_data).__finalize__(self)
5463+
f = lambda: self._mgr.consolidate()
5464+
cons_data = self._protect_consolidate(f)
5465+
return self._constructor(cons_data).__finalize__(self)
54755466

54765467
@property
54775468
def _is_mixed_type(self) -> bool_t:

pandas/core/reshape/concat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def __init__(
360360
raise TypeError(msg)
361361

362362
# consolidate
363-
obj._consolidate(inplace=True)
363+
obj._consolidate_inplace()
364364
ndims.add(obj.ndim)
365365

366366
# get the sample

pandas/tests/frame/test_block_internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_consolidate(self, float_frame):
6464
float_frame["F"] = 8.0
6565
assert len(float_frame._mgr.blocks) == 3
6666

67-
return_value = float_frame._consolidate(inplace=True)
67+
return_value = float_frame._consolidate_inplace()
6868
assert return_value is None
6969
assert len(float_frame._mgr.blocks) == 1
7070

pandas/tests/generic/test_frame.py

-3
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ def test_validate_bool_args(self, value):
189189
with pytest.raises(ValueError, match=msg):
190190
super(DataFrame, df).drop("a", axis=1, inplace=value)
191191

192-
with pytest.raises(ValueError, match=msg):
193-
super(DataFrame, df)._consolidate(inplace=value)
194-
195192
with pytest.raises(ValueError, match=msg):
196193
super(DataFrame, df).fillna(value=0, inplace=value)
197194

0 commit comments

Comments
 (0)