Skip to content

Commit 3beb122

Browse files
committed
DEPR: deprecate get_ftype_counts (GH18243)
Code review changes, simplify test case
1 parent 9bd5d95 commit 3beb122

File tree

3 files changed

+4
-45
lines changed

3 files changed

+4
-45
lines changed

pandas/core/generic.py

-35
Original file line numberDiff line numberDiff line change
@@ -4712,42 +4712,7 @@ def get_ftype_counts(self):
47124712
warnings.warn("get_ftype_counts is deprecated and will "
47134713
"be removed in a future version",
47144714
FutureWarning, stacklevel=2)
4715-
return self._get_ftype_counts()
47164715

4717-
def _get_ftype_counts(self):
4718-
"""
4719-
Return counts of unique ftypes in this object.
4720-
4721-
This is useful for SparseDataFrame or for DataFrames containing
4722-
sparse arrays.
4723-
4724-
Returns
4725-
-------
4726-
dtype : Series
4727-
Series with the count of columns with each type and
4728-
sparsity (dense/sparse)
4729-
4730-
See Also
4731-
--------
4732-
ftypes : Return ftypes (indication of sparse/dense and dtype) in
4733-
this object.
4734-
4735-
Examples
4736-
--------
4737-
>>> a = [['a', 1, 1.0], ['b', 2, 2.0], ['c', 3, 3.0]]
4738-
>>> df = pd.DataFrame(a, columns=['str', 'int', 'float'])
4739-
>>> df
4740-
str int float
4741-
0 a 1 1.0
4742-
1 b 2 2.0
4743-
2 c 3 3.0
4744-
4745-
>>> df._get_ftype_counts()
4746-
float64:dense 1
4747-
int64:dense 1
4748-
object:dense 1
4749-
dtype: int64
4750-
"""
47514716
from pandas import Series
47524717
return Series(self._data.get_ftype_counts())
47534718

pandas/tests/generic/test_generic.py

-8
Original file line numberDiff line numberDiff line change
@@ -1008,11 +1008,3 @@ def test_pipe_panel(self):
10081008

10091009
with pytest.raises(ValueError):
10101010
result = wp.pipe((f, 'y'), x=1, y=1)
1011-
1012-
# GH18243
1013-
def test_get_ftype_counts_deprecated(self):
1014-
a = [['a', 1, 1.0], ['b', 2, 2.0], ['c', 3, 3.0]]
1015-
df = DataFrame(a, columns=['str', 'int', 'float'])
1016-
1017-
with tm.assert_produces_warning(FutureWarning):
1018-
df.get_ftype_counts()

pandas/tests/series/test_dtypes.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ def test_dtype(self):
6464
assert self.ts.ftypes == 'float64:dense'
6565
tm.assert_series_equal(self.ts.get_dtype_counts(),
6666
Series(1, ['float64']))
67-
tm.assert_series_equal(self.ts._get_ftype_counts(),
68-
Series(1, ['float64:dense']))
67+
#GH18243 - Assert .get_ftype_counts is deprecated
68+
with tm.assert_produces_warning(FutureWarning):
69+
tm.assert_series_equal(self.ts.get_ftype_counts(),
70+
Series(1, ['float64:dense']))
6971

7072
@pytest.mark.parametrize("value", [np.nan, np.inf])
7173
@pytest.mark.parametrize("dtype", [np.int32, np.int64])

0 commit comments

Comments
 (0)