Skip to content

Commit ab64dd7

Browse files
jbrockmendeljreback
authored andcommitted
DEPR: ftype, ftypes (#29895)
1 parent 2b358a6 commit ab64dd7

File tree

10 files changed

+4
-184
lines changed

10 files changed

+4
-184
lines changed

doc/redirects.csv

-7
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,8 @@ generated/pandas.DataFrame.from_csv,../reference/api/pandas.DataFrame.from_csv
357357
generated/pandas.DataFrame.from_dict,../reference/api/pandas.DataFrame.from_dict
358358
generated/pandas.DataFrame.from_items,../reference/api/pandas.DataFrame.from_items
359359
generated/pandas.DataFrame.from_records,../reference/api/pandas.DataFrame.from_records
360-
generated/pandas.DataFrame.ftypes,../reference/api/pandas.DataFrame.ftypes
361360
generated/pandas.DataFrame.ge,../reference/api/pandas.DataFrame.ge
362361
generated/pandas.DataFrame.get_dtype_counts,../reference/api/pandas.DataFrame.get_dtype_counts
363-
generated/pandas.DataFrame.get_ftype_counts,../reference/api/pandas.DataFrame.get_ftype_counts
364362
generated/pandas.DataFrame.get,../reference/api/pandas.DataFrame.get
365363
generated/pandas.DataFrame.get_value,../reference/api/pandas.DataFrame.get_value
366364
generated/pandas.DataFrame.get_values,../reference/api/pandas.DataFrame.get_values
@@ -883,10 +881,8 @@ generated/pandas.Panel.first_valid_index,../reference/api/pandas.Panel.first_val
883881
generated/pandas.Panel.floordiv,../reference/api/pandas.Panel.floordiv
884882
generated/pandas.Panel.from_dict,../reference/api/pandas.Panel.from_dict
885883
generated/pandas.Panel.fromDict,../reference/api/pandas.Panel.fromDict
886-
generated/pandas.Panel.ftypes,../reference/api/pandas.Panel.ftypes
887884
generated/pandas.Panel.ge,../reference/api/pandas.Panel.ge
888885
generated/pandas.Panel.get_dtype_counts,../reference/api/pandas.Panel.get_dtype_counts
889-
generated/pandas.Panel.get_ftype_counts,../reference/api/pandas.Panel.get_ftype_counts
890886
generated/pandas.Panel.get,../reference/api/pandas.Panel.get
891887
generated/pandas.Panel.get_value,../reference/api/pandas.Panel.get_value
892888
generated/pandas.Panel.get_values,../reference/api/pandas.Panel.get_values
@@ -1223,11 +1219,8 @@ generated/pandas.Series.flags,../reference/api/pandas.Series.flags
12231219
generated/pandas.Series.floordiv,../reference/api/pandas.Series.floordiv
12241220
generated/pandas.Series.from_array,../reference/api/pandas.Series.from_array
12251221
generated/pandas.Series.from_csv,../reference/api/pandas.Series.from_csv
1226-
generated/pandas.Series.ftype,../reference/api/pandas.Series.ftype
1227-
generated/pandas.Series.ftypes,../reference/api/pandas.Series.ftypes
12281222
generated/pandas.Series.ge,../reference/api/pandas.Series.ge
12291223
generated/pandas.Series.get_dtype_counts,../reference/api/pandas.Series.get_dtype_counts
1230-
generated/pandas.Series.get_ftype_counts,../reference/api/pandas.Series.get_ftype_counts
12311224
generated/pandas.Series.get,../reference/api/pandas.Series.get
12321225
generated/pandas.Series.get_value,../reference/api/pandas.Series.get_value
12331226
generated/pandas.Series.get_values,../reference/api/pandas.Series.get_values

doc/source/reference/frame.rst

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Attributes and underlying data
2828
:toctree: api/
2929

3030
DataFrame.dtypes
31-
DataFrame.ftypes
3231
DataFrame.get_dtype_counts
3332
DataFrame.select_dtypes
3433
DataFrame.values

doc/source/reference/series.rst

-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Attributes
2929
Series.array
3030
Series.values
3131
Series.dtype
32-
Series.ftype
3332
Series.shape
3433
Series.nbytes
3534
Series.ndim
@@ -43,7 +42,6 @@ Attributes
4342
Series.flags
4443
Series.empty
4544
Series.dtypes
46-
Series.ftypes
4745
Series.data
4846
Series.name
4947
Series.put

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
440440
- Removed the previously deprecated :meth:`Series.valid`; use :meth:`Series.dropna` instead (:issue:`18800`)
441441
- Removed the previously properties :attr:`DataFrame.is_copy`, :attr:`Series.is_copy` (:issue:`18812`)
442442
- Removed the previously deprecated :meth:`DataFrame.get_ftype_counts`, :meth:`Series.get_ftype_counts` (:issue:`18243`)
443+
- Removed the previously deprecated :meth:`DataFrame.ftypes`, :meth:`Series.ftypes`, :meth:`Series.ftype` (:issue:`26744`)
443444
- Removed the previously deprecated :meth:`Index.get_duplicated`, use ``idx[idx.duplicated()].unique()`` instead (:issue:`20239`)
444445
- Removed the previously deprecated :meth:`Series.clip_upper`, :meth:`Series.clip_lower`, :meth:`DataFrame.clip_upper`, :meth:`DataFrame.clip_lower` (:issue:`24203`)
445446
- Removed the ability to alter :attr:`DatetimeIndex.freq`, :attr:`TimedeltaIndex.freq`, or :attr:`PeriodIndex.freq` (:issue:`20772`)

pandas/core/generic.py

+1-56
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ class NDFrame(PandasObject, SelectionMixin):
171171
]
172172
_internal_names_set: Set[str] = set(_internal_names)
173173
_accessors: Set[str] = set()
174-
_deprecations: FrozenSet[str] = frozenset(
175-
["get_dtype_counts", "get_values", "ftypes", "ix"]
176-
)
174+
_deprecations: FrozenSet[str] = frozenset(["get_dtype_counts", "get_values", "ix"])
177175
_metadata: List[str] = []
178176
_is_copy = None
179177
_data: BlockManager
@@ -5582,10 +5580,6 @@ def dtypes(self):
55825580
pandas.Series
55835581
The data type of each column.
55845582
5585-
See Also
5586-
--------
5587-
DataFrame.ftypes : Dtype and sparsity information.
5588-
55895583
Examples
55905584
--------
55915585
>>> df = pd.DataFrame({'float': [1.0],
@@ -5603,55 +5597,6 @@ def dtypes(self):
56035597

56045598
return Series(self._data.get_dtypes(), index=self._info_axis, dtype=np.object_)
56055599

5606-
@property
5607-
def ftypes(self):
5608-
"""
5609-
Return the ftypes (indication of sparse/dense and dtype) in DataFrame.
5610-
5611-
.. deprecated:: 0.25.0
5612-
Use :func:`dtypes` instead.
5613-
5614-
This returns a Series with the data type of each column.
5615-
The result's index is the original DataFrame's columns. Columns
5616-
with mixed types are stored with the ``object`` dtype. See
5617-
:ref:`the User Guide <basics.dtypes>` for more.
5618-
5619-
Returns
5620-
-------
5621-
pandas.Series
5622-
The data type and indication of sparse/dense of each column.
5623-
5624-
See Also
5625-
--------
5626-
DataFrame.dtypes: Series with just dtype information.
5627-
5628-
Notes
5629-
-----
5630-
Sparse data should have the same dtypes as its dense representation.
5631-
5632-
Examples
5633-
--------
5634-
>>> arr = np.random.RandomState(0).randn(100, 4)
5635-
>>> arr[arr < .8] = np.nan
5636-
>>> pd.DataFrame(arr).ftypes
5637-
0 float64:dense
5638-
1 float64:dense
5639-
2 float64:dense
5640-
3 float64:dense
5641-
dtype: object
5642-
"""
5643-
warnings.warn(
5644-
"DataFrame.ftypes is deprecated and will "
5645-
"be removed in a future version. "
5646-
"Use DataFrame.dtypes instead.",
5647-
FutureWarning,
5648-
stacklevel=2,
5649-
)
5650-
5651-
from pandas import Series
5652-
5653-
return Series(self._data.get_ftypes(), index=self._info_axis, dtype=np.object_)
5654-
56555600
def _to_dict_of_blocks(self, copy=True):
56565601
"""
56575602
Return a dict of dtype -> Constructor Types that

pandas/core/internals/managers.py

-12
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class BlockManager(PandasObject):
8282
8383
get_dtype_counts
8484
get_dtypes
85-
get_ftypes
8685
8786
apply(func, axes, block_filter_fn)
8887
@@ -251,10 +250,6 @@ def get_dtypes(self):
251250
dtypes = np.array([blk.dtype for blk in self.blocks])
252251
return algos.take_1d(dtypes, self._blknos, allow_fill=False)
253252

254-
def get_ftypes(self):
255-
ftypes = np.array([blk.ftype for blk in self.blocks])
256-
return algos.take_1d(ftypes, self._blknos, allow_fill=False)
257-
258253
def __getstate__(self):
259254
block_values = [b.values for b in self.blocks]
260255
block_items = [self.items[b.mgr_locs.indexer] for b in self.blocks]
@@ -1546,19 +1541,12 @@ def dtype(self):
15461541
def array_dtype(self):
15471542
return self._block.array_dtype
15481543

1549-
@property
1550-
def ftype(self):
1551-
return self._block.ftype
1552-
15531544
def get_dtype_counts(self):
15541545
return {self.dtype.name: 1}
15551546

15561547
def get_dtypes(self):
15571548
return np.array([self._block.dtype])
15581549

1559-
def get_ftypes(self):
1560-
return np.array([self._block.ftype])
1561-
15621550
def external_values(self):
15631551
return self._block.external_values()
15641552

pandas/core/series.py

+1-39
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
158158
_deprecations = (
159159
base.IndexOpsMixin._deprecations
160160
| generic.NDFrame._deprecations
161-
| frozenset(
162-
["compress", "valid", "ftype", "real", "imag", "put", "ptp", "nonzero"]
163-
)
161+
| frozenset(["compress", "valid", "real", "imag", "put", "ptp", "nonzero"])
164162
)
165163

166164
# Override cache_readonly bc Series is mutable
@@ -418,42 +416,6 @@ def name(self, value: Optional[Hashable]) -> None:
418416
raise TypeError("Series.name must be a hashable type")
419417
self.attrs["name"] = value
420418

421-
@property
422-
def ftype(self):
423-
"""
424-
Return if the data is sparse|dense.
425-
426-
.. deprecated:: 0.25.0
427-
Use :func:`dtype` instead.
428-
"""
429-
warnings.warn(
430-
"Series.ftype is deprecated and will "
431-
"be removed in a future version. "
432-
"Use Series.dtype instead.",
433-
FutureWarning,
434-
stacklevel=2,
435-
)
436-
437-
return self._data.ftype
438-
439-
@property
440-
def ftypes(self):
441-
"""
442-
Return if the data is sparse|dense.
443-
444-
.. deprecated:: 0.25.0
445-
Use :func:`dtypes` instead.
446-
"""
447-
warnings.warn(
448-
"Series.ftypes is deprecated and will "
449-
"be removed in a future version. "
450-
"Use Series.dtype instead.",
451-
FutureWarning,
452-
stacklevel=2,
453-
)
454-
455-
return self._data.ftype
456-
457419
@property
458420
def values(self):
459421
"""

pandas/tests/frame/test_dtypes.py

+1-47
Original file line numberDiff line numberDiff line change
@@ -46,63 +46,33 @@ def test_concat_empty_dataframe_dtypes(self):
4646
assert result["b"].dtype == np.float64
4747
assert result["c"].dtype == np.float64
4848

49-
def test_empty_frame_dtypes_ftypes(self):
49+
def test_empty_frame_dtypes(self):
5050
empty_df = pd.DataFrame()
5151
tm.assert_series_equal(empty_df.dtypes, pd.Series(dtype=np.object))
5252

53-
# GH 26705 - Assert .ftypes is deprecated
54-
with tm.assert_produces_warning(FutureWarning):
55-
tm.assert_series_equal(empty_df.ftypes, pd.Series(dtype=np.object))
56-
5753
nocols_df = pd.DataFrame(index=[1, 2, 3])
5854
tm.assert_series_equal(nocols_df.dtypes, pd.Series(dtype=np.object))
5955

60-
# GH 26705 - Assert .ftypes is deprecated
61-
with tm.assert_produces_warning(FutureWarning):
62-
tm.assert_series_equal(nocols_df.ftypes, pd.Series(dtype=np.object))
63-
6456
norows_df = pd.DataFrame(columns=list("abc"))
6557
tm.assert_series_equal(
6658
norows_df.dtypes, pd.Series(np.object, index=list("abc"))
6759
)
6860

69-
# GH 26705 - Assert .ftypes is deprecated
70-
with tm.assert_produces_warning(FutureWarning):
71-
tm.assert_series_equal(
72-
norows_df.ftypes, pd.Series("object:dense", index=list("abc"))
73-
)
74-
7561
norows_int_df = pd.DataFrame(columns=list("abc")).astype(np.int32)
7662
tm.assert_series_equal(
7763
norows_int_df.dtypes, pd.Series(np.dtype("int32"), index=list("abc"))
7864
)
79-
# GH 26705 - Assert .ftypes is deprecated
80-
with tm.assert_produces_warning(FutureWarning):
81-
tm.assert_series_equal(
82-
norows_int_df.ftypes, pd.Series("int32:dense", index=list("abc"))
83-
)
8465

8566
odict = OrderedDict
8667
df = pd.DataFrame(odict([("a", 1), ("b", True), ("c", 1.0)]), index=[1, 2, 3])
8768
ex_dtypes = pd.Series(
8869
odict([("a", np.int64), ("b", np.bool), ("c", np.float64)])
8970
)
90-
ex_ftypes = pd.Series(
91-
odict([("a", "int64:dense"), ("b", "bool:dense"), ("c", "float64:dense")])
92-
)
9371
tm.assert_series_equal(df.dtypes, ex_dtypes)
9472

95-
# GH 26705 - Assert .ftypes is deprecated
96-
with tm.assert_produces_warning(FutureWarning):
97-
tm.assert_series_equal(df.ftypes, ex_ftypes)
98-
9973
# same but for empty slice of df
10074
tm.assert_series_equal(df[:0].dtypes, ex_dtypes)
10175

102-
# GH 26705 - Assert .ftypes is deprecated
103-
with tm.assert_produces_warning(FutureWarning):
104-
tm.assert_series_equal(df[:0].ftypes, ex_ftypes)
105-
10676
def test_datetime_with_tz_dtypes(self):
10777
tzframe = DataFrame(
10878
{
@@ -474,22 +444,6 @@ def test_dtypes_gh8722(self, float_string_frame):
474444
result = df.dtypes
475445
tm.assert_series_equal(result, Series({0: np.dtype("int64")}))
476446

477-
def test_ftypes(self, mixed_float_frame):
478-
frame = mixed_float_frame
479-
expected = Series(
480-
dict(
481-
A="float32:dense",
482-
B="float32:dense",
483-
C="float16:dense",
484-
D="float64:dense",
485-
)
486-
).sort_values()
487-
488-
# GH 26705 - Assert .ftypes is deprecated
489-
with tm.assert_produces_warning(FutureWarning):
490-
result = frame.ftypes.sort_values()
491-
tm.assert_series_equal(result, expected)
492-
493447
def test_astype_float(self, float_frame):
494448
casted = float_frame.astype(int)
495449
expected = DataFrame(

pandas/tests/series/test_combine_concat.py

-12
Original file line numberDiff line numberDiff line change
@@ -290,32 +290,20 @@ def test_concat_empty_series_dtypes(self):
290290
)
291291
assert result.dtype == "Sparse[float64]"
292292

293-
# GH 26705 - Assert .ftype is deprecated
294-
with tm.assert_produces_warning(FutureWarning):
295-
assert result.ftype == "float64:sparse"
296-
297293
result = pd.concat(
298294
[Series(dtype="float64").astype("Sparse"), Series(dtype="float64")]
299295
)
300296
# TODO: release-note: concat sparse dtype
301297
expected = pd.SparseDtype(np.float64)
302298
assert result.dtype == expected
303299

304-
# GH 26705 - Assert .ftype is deprecated
305-
with tm.assert_produces_warning(FutureWarning):
306-
assert result.ftype == "float64:sparse"
307-
308300
result = pd.concat(
309301
[Series(dtype="float64").astype("Sparse"), Series(dtype="object")]
310302
)
311303
# TODO: release-note: concat sparse dtype
312304
expected = pd.SparseDtype("object")
313305
assert result.dtype == expected
314306

315-
# GH 26705 - Assert .ftype is deprecated
316-
with tm.assert_produces_warning(FutureWarning):
317-
assert result.ftype == "object:sparse"
318-
319307
def test_combine_first_dt64(self):
320308
from pandas.core.tools.datetimes import to_datetime
321309

pandas/tests/series/test_dtypes.py

-8
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ def test_dtype(self, datetime_series):
4949
assert datetime_series.dtype == np.dtype("float64")
5050
assert datetime_series.dtypes == np.dtype("float64")
5151

52-
# GH 26705 - Assert .ftype is deprecated
53-
with tm.assert_produces_warning(FutureWarning):
54-
assert datetime_series.ftype == "float64:dense"
55-
56-
# GH 26705 - Assert .ftypes is deprecated
57-
with tm.assert_produces_warning(FutureWarning):
58-
assert datetime_series.ftypes == "float64:dense"
59-
6052
@pytest.mark.parametrize("value", [np.nan, np.inf])
6153
@pytest.mark.parametrize("dtype", [np.int32, np.int64])
6254
def test_astype_cast_nan_inf_int(self, dtype, value):

0 commit comments

Comments
 (0)