Skip to content

Commit b13a499

Browse files
committed
DEPR: deprecate is_any_int_dtype and is_floating_dtype from pandas.api.types
xref pandas-dev#16042
1 parent 075eca1 commit b13a499

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

doc/source/whatsnew/v0.20.0.txt

Lines changed: 1 addition & 0 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 22 additions & 3 deletions
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

Lines changed: 11 additions & 3 deletions
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)