Skip to content

DEPR: deprecate get_ftype_counts (GH18243) #20404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
6 changes: 6 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -4707,6 +4709,10 @@ def get_ftype_counts(self):
object:dense 1
dtype: int64
"""
warnings.warn("get_ftype_counts is deprecated and will "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to create another function here, this is purely user facing (IOW don't create a _get_ftype_counts). keep the doc-string though.

"be removed in a future version",
FutureWarning, stacklevel=2)

from pandas import Series
return Series(self._data.get_ftype_counts())

Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/series/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just assert the warning here

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])
Expand Down