Skip to content

Deprecated Series.ftype, Series.ftypes and DataFrame.ftypes features #26744

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
merged 15 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 8 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5525,6 +5525,9 @@ def ftypes(self):
"""
Return the ftypes (indication of sparse/dense and dtype) in DataFrame.

.. deprecated:: 0.25.0
Use :func:`dtypes` instead.

This returns a Series with the data type of each column.
The result's index is the original DataFrame's columns. Columns
with mixed types are stored with the ``object`` dtype. See
Expand Down Expand Up @@ -5562,6 +5565,11 @@ def ftypes(self):
3 float64:sparse
dtype: object
"""
warnings.warn("ftypes is deprecated and will "
"be removed in a future version. "
"Use dtypes instead.",
FutureWarning, stacklevel=2)

from pandas import Series
return Series(self._data.get_ftypes(), index=self._info_axis,
dtype=np.object_)
Expand Down
16 changes: 16 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,30 @@ def dtypes(self):
def ftype(self):
"""
Return if the data is sparse|dense.

.. deprecated:: 0.25.0
Use :func:`dtype` instead.
"""
warnings.warn("ftype is deprecated and will "
"be removed in a future version. "
"Use dtype instead.",
FutureWarning, stacklevel=2)

return self._data.ftype

@property
def ftypes(self):
"""
Return if the data is sparse|dense.

.. deprecated:: 0.25.0
Use :func:`dtypes` instead.
"""
warnings.warn("ftypes is deprecated and will "
"be removed in a future version. "
"Use dtypes instead.",
FutureWarning, stacklevel=2)

return self._data.ftype

@property
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/frame/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ def test_ftypes(self):
B='float32:dense',
C='float16:dense',
D='float64:dense')).sort_values()
result = frame.ftypes.sort_values()
with tm.assert_produces_warning(FutureWarning):
result = frame.ftypes.sort_values()
assert_series_equal(result, expected)

def test_astype(self):
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 @@ -48,8 +48,10 @@ def test_dtype(self, datetime_series):

assert datetime_series.dtype == np.dtype('float64')
assert datetime_series.dtypes == np.dtype('float64')
assert datetime_series.ftype == 'float64:dense'
assert datetime_series.ftypes == 'float64:dense'
with tm.assert_produces_warning(FutureWarning):
assert datetime_series.ftype == 'float64:dense'
with tm.assert_produces_warning(FutureWarning):
assert datetime_series.ftypes == 'float64:dense'
tm.assert_series_equal(datetime_series.get_dtype_counts(),
Series(1, ['float64']))
# GH18243 - Assert .get_ftype_counts is deprecated
Expand Down