Skip to content
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

DEPR: deprecate is_any_int_dtype and is_floating_dtype from pandas.api.types #16163

Merged
merged 3 commits into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
26 changes: 26 additions & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1939,3 +1939,29 @@ Data types related functionality
api.types.union_categoricals
api.types.infer_dtype
api.types.pandas_dtype

Dtype introspection

.. autosummary::
:toctree: generated/

api.types.is_bool_dtype
api.types.is_categorical_dtype
api.types.is_complex_dtype
api.types.is_datetime64_any_dtype
api.types.is_datetime64_dtype
api.types.is_datetime64_ns_dtype
api.types.is_datetime64tz_dtype
api.types.is_extension_type
api.types.is_float_dtype
api.types.is_int64_dtype
api.types.is_integer_dtype
api.types.is_interval_dtype
api.types.is_numeric_dtype
api.types.is_object_dtype
api.types.is_period_dtype
api.types.is_signed_integer_dtype
api.types.is_string_dtype
api.types.is_timedelta64_dtype
api.types.is_timedelta64_ns_dtype
api.types.is_unsigned_integer_dtype
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,7 @@ Other Deprecations
* ``pd.match()``, is removed.
* ``pd.groupby()``, replaced by using the ``.groupby()`` method directly on a ``Series/DataFrame``
* ``pd.get_store()``, replaced by a direct call to ``pd.HDFStore(...)``
- ``is_any_int_dtype`` and ``is_floating_dtype`` are deprecated from ``pandas.api.types`` (:issue:`16042`)

.. _whatsnew_0200.prior_deprecations:

Expand Down
1 change: 0 additions & 1 deletion pandas/api/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
IntervalDtype)
from pandas.core.dtypes.concat import union_categoricals # noqa
from pandas._libs.lib import infer_dtype # noqa
del np # noqa
25 changes: 22 additions & 3 deletions pandas/core/dtypes/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# flake8: noqa

import numpy as np
import sys

from .common import (pandas_dtype,
is_dtype_equal,
Expand Down Expand Up @@ -40,12 +40,10 @@
is_float,
is_complex,
is_number,
is_any_int_dtype,
is_integer_dtype,
is_int64_dtype,
is_numeric_dtype,
is_float_dtype,
is_floating_dtype,
is_bool_dtype,
is_complex_dtype,
is_signed_integer_dtype,
Expand All @@ -61,3 +59,24 @@
is_hashable,
is_named_tuple,
is_sequence)


# deprecated
m = sys.modules['pandas.core.dtypes.api']

for t in ['is_any_int_dtype', 'is_floating_dtype']:

def outer(t=t):

def wrapper(arr_or_dtype):
import warnings
import pandas
warnings.warn("{t} is deprecated and will be "
"removed in a future version".format(t=t),
FutureWarning, stacklevel=3)
return getattr(pandas.core.dtypes.common, t)(arr_or_dtype)
return wrapper

setattr(m, t, outer(t))

del sys, m, t, outer
14 changes: 11 additions & 3 deletions pandas/tests/api/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

class TestTypes(Base, tm.TestCase):

allowed = ['is_any_int_dtype', 'is_bool', 'is_bool_dtype',
allowed = ['is_bool', 'is_bool_dtype',
'is_categorical', 'is_categorical_dtype', 'is_complex',
'is_complex_dtype', 'is_datetime64_any_dtype',
'is_datetime64_dtype', 'is_datetime64_ns_dtype',
'is_datetime64tz_dtype', 'is_datetimetz', 'is_dtype_equal',
'is_extension_type', 'is_float', 'is_float_dtype',
'is_floating_dtype', 'is_int64_dtype', 'is_integer',
'is_int64_dtype', 'is_integer',
'is_integer_dtype', 'is_number', 'is_numeric_dtype',
'is_object_dtype', 'is_scalar', 'is_sparse',
'is_string_dtype', 'is_signed_integer_dtype',
Expand All @@ -33,12 +33,13 @@ class TestTypes(Base, tm.TestCase):
'is_list_like', 'is_hashable',
'is_named_tuple', 'is_sequence',
'pandas_dtype', 'union_categoricals', 'infer_dtype']
deprecated = ['is_any_int_dtype', 'is_floating_dtype']
dtypes = ['CategoricalDtype', 'DatetimeTZDtype',
'PeriodDtype', 'IntervalDtype']

def test_types(self):

self.check(types, self.allowed + self.dtypes)
self.check(types, self.allowed + self.dtypes + self.deprecated)

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

def test_deprecated_from_api_types(self):

for t in ['is_any_int_dtype', 'is_floating_dtype']:
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
getattr(types, t)(1)


def test_moved_infer_dtype():

Expand Down