Skip to content

Commit 3b242b4

Browse files
DEPR: rename to _consolidate and create deprecation warning
DEPR: rename to _consolidate and create deprecation warning DEPR: renamed consolidate and created deprecation error
1 parent b94186d commit 3b242b4

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

doc/source/whatsnew/v0.20.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ Deprecations
484484
- ``DataFrame.astype()`` has deprecated the ``raise_on_error`` parameter in favor of ``errors`` (:issue:`14878`)
485485
- ``Series.sortlevel`` and ``DataFrame.sortlevel`` have been deprecated in favor of ``Series.sort_index`` and ``DataFrame.sort_index`` (:issue:`15099`)
486486
- importing ``concat`` from ``pandas.tools.merge`` has been deprecated in favor of imports from the ``pandas`` namespace. This should only affect explict imports (:issue:`15358`)
487+
- ``DataFrame.consolidate()`` has been deprecated. (:issue:`15483`)
487488

488489
.. _whatsnew_0200.prior_deprecations:
489490

pandas/core/generic.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -2874,11 +2874,20 @@ def f():
28742874

28752875
self._protect_consolidate(f)
28762876

2877+
def _consolidate(self, inplace=False):
2878+
# 15483
2879+
warnings.warn("consolidate is deprecated and will be removed in a "
2880+
"future release.", DeprecationWarning, stacklevel=2)
2881+
f = lambda: self._data.consolidate()
2882+
cons_data = self._protect_consolidate(f)
2883+
return self._constructor(cons_data).__finalize__(self)
2884+
28772885
def consolidate(self, inplace=False):
28782886
"""
2887+
DEPRECATED:
2888+
28792889
Compute NDFrame with "consolidated" internals (data of each dtype
2880-
grouped together in a single ndarray). Mainly an internal API function,
2881-
but available here to the savvy user
2890+
grouped together in a single ndarray).
28822891
28832892
Parameters
28842893
----------
@@ -2893,9 +2902,7 @@ def consolidate(self, inplace=False):
28932902
if inplace:
28942903
self._consolidate_inplace()
28952904
else:
2896-
f = lambda: self._data.consolidate()
2897-
cons_data = self._protect_consolidate(f)
2898-
return self._constructor(cons_data).__finalize__(self)
2905+
return self._consolidate(inplace=False)
28992906

29002907
@property
29012908
def _is_mixed_type(self):

0 commit comments

Comments
 (0)