Skip to content

Commit 2d73198

Browse files
jrebackpcluo
authored andcommitted
DEPR: deprecate is_any_int_dtype and is_floating_dtype from pandas.api.types (pandas-dev#16163)
* DEPR: deprecate is_any_int_dtype and is_floating_dtype from pandas.api.types closes pandas-dev#16042 * is_ docs
1 parent 89ccb54 commit 2d73198

File tree

5 files changed

+92
-7
lines changed

5 files changed

+92
-7
lines changed

doc/source/api.rst

+58
Original file line numberDiff line numberDiff line change
@@ -1939,3 +1939,61 @@ Data types related functionality
19391939
api.types.union_categoricals
19401940
api.types.infer_dtype
19411941
api.types.pandas_dtype
1942+
1943+
Dtype introspection
1944+
1945+
.. autosummary::
1946+
:toctree: generated/
1947+
1948+
api.types.is_bool_dtype
1949+
api.types.is_categorical_dtype
1950+
api.types.is_complex_dtype
1951+
api.types.is_datetime64_any_dtype
1952+
api.types.is_datetime64_dtype
1953+
api.types.is_datetime64_ns_dtype
1954+
api.types.is_datetime64tz_dtype
1955+
api.types.is_extension_type
1956+
api.types.is_float_dtype
1957+
api.types.is_int64_dtype
1958+
api.types.is_integer_dtype
1959+
api.types.is_interval_dtype
1960+
api.types.is_numeric_dtype
1961+
api.types.is_object_dtype
1962+
api.types.is_period_dtype
1963+
api.types.is_signed_integer_dtype
1964+
api.types.is_string_dtype
1965+
api.types.is_timedelta64_dtype
1966+
api.types.is_timedelta64_ns_dtype
1967+
api.types.is_unsigned_integer_dtype
1968+
api.types.is_sparse
1969+
1970+
Iterable introspection
1971+
1972+
api.types.is_dict_like
1973+
api.types.is_file_like
1974+
api.types.is_list_like
1975+
api.types.is_named_tuple
1976+
api.types.is_iterator
1977+
api.types.is_sequence
1978+
1979+
.. autosummary::
1980+
:toctree: generated/
1981+
1982+
Scalar introspection
1983+
1984+
.. autosummary::
1985+
:toctree: generated/
1986+
1987+
api.types.is_bool
1988+
api.types.is_categorical
1989+
api.types.is_complex
1990+
api.types.is_datetimetz
1991+
api.types.is_float
1992+
api.types.is_hashable
1993+
api.types.is_integer
1994+
api.types.is_interval
1995+
api.types.is_number
1996+
api.types.is_period
1997+
api.types.is_re
1998+
api.types.is_re_compilable
1999+
api.types.is_scalar

doc/source/whatsnew/v0.20.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,7 @@ Other Deprecations
15201520
* ``pd.match()``, is removed.
15211521
* ``pd.groupby()``, replaced by using the ``.groupby()`` method directly on a ``Series/DataFrame``
15221522
* ``pd.get_store()``, replaced by a direct call to ``pd.HDFStore(...)``
1523+
- ``is_any_int_dtype`` and ``is_floating_dtype`` are deprecated from ``pandas.api.types`` (:issue:`16042`)
15231524

15241525
.. _whatsnew_0200.prior_deprecations:
15251526

pandas/api/types/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
IntervalDtype)
88
from pandas.core.dtypes.concat import union_categoricals # noqa
99
from pandas._libs.lib import infer_dtype # noqa
10-
del np # noqa

pandas/core/dtypes/api.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# flake8: noqa
22

3-
import numpy as np
3+
import sys
44

55
from .common import (pandas_dtype,
66
is_dtype_equal,
@@ -40,12 +40,10 @@
4040
is_float,
4141
is_complex,
4242
is_number,
43-
is_any_int_dtype,
4443
is_integer_dtype,
4544
is_int64_dtype,
4645
is_numeric_dtype,
4746
is_float_dtype,
48-
is_floating_dtype,
4947
is_bool_dtype,
5048
is_complex_dtype,
5149
is_signed_integer_dtype,
@@ -61,3 +59,24 @@
6159
is_hashable,
6260
is_named_tuple,
6361
is_sequence)
62+
63+
64+
# deprecated
65+
m = sys.modules['pandas.core.dtypes.api']
66+
67+
for t in ['is_any_int_dtype', 'is_floating_dtype']:
68+
69+
def outer(t=t):
70+
71+
def wrapper(arr_or_dtype):
72+
import warnings
73+
import pandas
74+
warnings.warn("{t} is deprecated and will be "
75+
"removed in a future version".format(t=t),
76+
FutureWarning, stacklevel=3)
77+
return getattr(pandas.core.dtypes.common, t)(arr_or_dtype)
78+
return wrapper
79+
80+
setattr(m, t, outer(t))
81+
82+
del sys, m, t, outer

pandas/tests/api/test_types.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
class TestTypes(Base, tm.TestCase):
1717

18-
allowed = ['is_any_int_dtype', 'is_bool', 'is_bool_dtype',
18+
allowed = ['is_bool', 'is_bool_dtype',
1919
'is_categorical', 'is_categorical_dtype', 'is_complex',
2020
'is_complex_dtype', 'is_datetime64_any_dtype',
2121
'is_datetime64_dtype', 'is_datetime64_ns_dtype',
2222
'is_datetime64tz_dtype', 'is_datetimetz', 'is_dtype_equal',
2323
'is_extension_type', 'is_float', 'is_float_dtype',
24-
'is_floating_dtype', 'is_int64_dtype', 'is_integer',
24+
'is_int64_dtype', 'is_integer',
2525
'is_integer_dtype', 'is_number', 'is_numeric_dtype',
2626
'is_object_dtype', 'is_scalar', 'is_sparse',
2727
'is_string_dtype', 'is_signed_integer_dtype',
@@ -33,12 +33,13 @@ class TestTypes(Base, tm.TestCase):
3333
'is_list_like', 'is_hashable',
3434
'is_named_tuple', 'is_sequence',
3535
'pandas_dtype', 'union_categoricals', 'infer_dtype']
36+
deprecated = ['is_any_int_dtype', 'is_floating_dtype']
3637
dtypes = ['CategoricalDtype', 'DatetimeTZDtype',
3738
'PeriodDtype', 'IntervalDtype']
3839

3940
def test_types(self):
4041

41-
self.check(types, self.allowed + self.dtypes)
42+
self.check(types, self.allowed + self.dtypes + self.deprecated)
4243

4344
def check_deprecation(self, fold, fnew):
4445
with tm.assert_produces_warning(DeprecationWarning):
@@ -87,6 +88,13 @@ def test_removed_from_core_common(self):
8788
'ensure_float']:
8889
pytest.raises(AttributeError, lambda: getattr(com, t))
8990

91+
def test_deprecated_from_api_types(self):
92+
93+
for t in ['is_any_int_dtype', 'is_floating_dtype']:
94+
with tm.assert_produces_warning(FutureWarning,
95+
check_stacklevel=False):
96+
getattr(types, t)(1)
97+
9098

9199
def test_moved_infer_dtype():
92100

0 commit comments

Comments
 (0)