diff --git a/doc/source/whatsnew/v0.23.0.txt b/doc/source/whatsnew/v0.23.0.txt index 151ab8456c1d7..dfb7f702f7d5c 100644 --- a/doc/source/whatsnew/v0.23.0.txt +++ b/doc/source/whatsnew/v0.23.0.txt @@ -741,6 +741,7 @@ Deprecations - ``pandas.tseries.plotting.tsplot`` is deprecated. Use :func:`Series.plot` instead (:issue:`18627`) - ``Index.summary()`` is deprecated and will be removed in a future version (:issue:`18217`) +- ``NDFrame.get_ftype_counts()`` is deprecated and will be removed in a future version (:issue:`18243`) .. _whatsnew_0230.prior_deprecations: diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 2adc289f98d94..7c9ec16304661 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4677,6 +4677,8 @@ def get_ftype_counts(self): """ Return counts of unique ftypes in this object. + .. deprecated:: 0.23.0 + This is useful for SparseDataFrame or for DataFrames containing sparse arrays. @@ -4707,6 +4709,10 @@ def get_ftype_counts(self): object:dense 1 dtype: int64 """ + warnings.warn("get_ftype_counts is deprecated and will " + "be removed in a future version", + FutureWarning, stacklevel=2) + from pandas import Series return Series(self._data.get_ftype_counts()) diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index 56ff092dd0a27..dd1b623f0f7ff 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -64,8 +64,10 @@ def test_dtype(self): assert self.ts.ftypes == 'float64:dense' tm.assert_series_equal(self.ts.get_dtype_counts(), Series(1, ['float64'])) - tm.assert_series_equal(self.ts.get_ftype_counts(), - Series(1, ['float64:dense'])) + # GH18243 - Assert .get_ftype_counts is deprecated + with tm.assert_produces_warning(FutureWarning): + tm.assert_series_equal(self.ts.get_ftype_counts(), + Series(1, ['float64:dense'])) @pytest.mark.parametrize("value", [np.nan, np.inf]) @pytest.mark.parametrize("dtype", [np.int32, np.int64])