From f098d58de43fa0ea6836da225fd007ebd603c0e6 Mon Sep 17 00:00:00 2001 From: Brock Date: Mon, 5 Oct 2020 17:45:11 -0700 Subject: [PATCH] CLN: remove inplace kwarg from NDFrame._consolidate --- pandas/core/generic.py | 17 ++++------------- pandas/core/reshape/concat.py | 2 +- pandas/tests/frame/test_block_internals.py | 2 +- pandas/tests/generic/test_frame.py | 3 --- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 04e1fc91c5fd4..8ccce9e5e451b 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -5447,27 +5447,18 @@ def f(): self._protect_consolidate(f) - def _consolidate(self, inplace: bool_t = False): + def _consolidate(self): """ Compute NDFrame with "consolidated" internals (data of each dtype grouped together in a single ndarray). - Parameters - ---------- - inplace : bool, default False - If False return new object, otherwise modify existing object. - Returns ------- consolidated : same type as caller """ - inplace = validate_bool_kwarg(inplace, "inplace") - if inplace: - self._consolidate_inplace() - else: - f = lambda: self._mgr.consolidate() - cons_data = self._protect_consolidate(f) - return self._constructor(cons_data).__finalize__(self) + f = lambda: self._mgr.consolidate() + cons_data = self._protect_consolidate(f) + return self._constructor(cons_data).__finalize__(self) @property def _is_mixed_type(self) -> bool_t: diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index a07c7b49ac55b..5a54e4e05dbad 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -360,7 +360,7 @@ def __init__( raise TypeError(msg) # consolidate - obj._consolidate(inplace=True) + obj._consolidate_inplace() ndims.add(obj.ndim) # get the sample diff --git a/pandas/tests/frame/test_block_internals.py b/pandas/tests/frame/test_block_internals.py index 1e404c572dd51..f5d2bd27762ef 100644 --- a/pandas/tests/frame/test_block_internals.py +++ b/pandas/tests/frame/test_block_internals.py @@ -64,7 +64,7 @@ def test_consolidate(self, float_frame): float_frame["F"] = 8.0 assert len(float_frame._mgr.blocks) == 3 - return_value = float_frame._consolidate(inplace=True) + return_value = float_frame._consolidate_inplace() assert return_value is None assert len(float_frame._mgr.blocks) == 1 diff --git a/pandas/tests/generic/test_frame.py b/pandas/tests/generic/test_frame.py index 31501f20db453..ad0d1face53cf 100644 --- a/pandas/tests/generic/test_frame.py +++ b/pandas/tests/generic/test_frame.py @@ -189,9 +189,6 @@ def test_validate_bool_args(self, value): with pytest.raises(ValueError, match=msg): super(DataFrame, df).drop("a", axis=1, inplace=value) - with pytest.raises(ValueError, match=msg): - super(DataFrame, df)._consolidate(inplace=value) - with pytest.raises(ValueError, match=msg): super(DataFrame, df).fillna(value=0, inplace=value)