diff --git a/doc/redirects.csv b/doc/redirects.csv index 8a55c48996e84..35bf56b9b824c 100644 --- a/doc/redirects.csv +++ b/doc/redirects.csv @@ -101,7 +101,6 @@ generated/pandas.api.types.infer_dtype,../reference/api/pandas.api.types.infer_d generated/pandas.api.types.is_bool_dtype,../reference/api/pandas.api.types.is_bool_dtype generated/pandas.api.types.is_bool,../reference/api/pandas.api.types.is_bool generated/pandas.api.types.is_categorical_dtype,../reference/api/pandas.api.types.is_categorical_dtype -generated/pandas.api.types.is_categorical,../reference/api/pandas.api.types.is_categorical generated/pandas.api.types.is_complex_dtype,../reference/api/pandas.api.types.is_complex_dtype generated/pandas.api.types.is_complex,../reference/api/pandas.api.types.is_complex generated/pandas.api.types.is_datetime64_any_dtype,../reference/api/pandas.api.types.is_datetime64_any_dtype diff --git a/doc/source/reference/arrays.rst b/doc/source/reference/arrays.rst index ad12ade41589e..17510a0b7d479 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -659,7 +659,6 @@ Scalar introspection :toctree: api/ api.types.is_bool - api.types.is_categorical api.types.is_complex api.types.is_float api.types.is_hashable diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 2ba3bd9470ff3..3e23108e28676 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -164,6 +164,7 @@ Removal of prior version deprecations/changes - Removed deprecated :meth:`CategoricalIndex.take_nd` (:issue:`30702`) - Removed deprecated :meth:`Index.is_type_compatible` (:issue:`42113`) - Removed deprecated :meth:`Index.is_mixed`, check ``index.inferred_type`` directly instead (:issue:`32922`) +- Removed deprecated :func:`pandas.api.types.is_categorical`; use :func:`pandas.api.types.is_categorical_dtype` instead (:issue:`33385`) - Removed deprecated :meth:`Index.asi8` (:issue:`37877`) - Enforced deprecation disallowing passing a timezone-aware :class:`Timestamp` and ``dtype="datetime64[ns]"`` to :class:`Series` or :class:`DataFrame` constructors (:issue:`41555`) - Enforced deprecation disallowing passing a sequence of timezone-aware values and ``dtype="datetime64[ns]"`` to to :class:`Series` or :class:`DataFrame` constructors (:issue:`41555`) diff --git a/pandas/conftest.py b/pandas/conftest.py index 24d878cf1cde9..94db244e19945 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -153,7 +153,6 @@ def pytest_collection_modifyitems(items, config) -> None: # Deprecations where the docstring will emit a warning ("DataFrame.append", "The frame.append method is deprecated"), ("Series.append", "The series.append method is deprecated"), - ("dtypes.common.is_categorical", "is_categorical is deprecated"), # Docstring divides by zero to show behavior difference ("missing.mask_zero_div_zero", "divide by zero encountered"), # Docstring demonstrates the call raises a warning diff --git a/pandas/core/dtypes/api.py b/pandas/core/dtypes/api.py index 0456073eaa7c6..00300c5c74e51 100644 --- a/pandas/core/dtypes/api.py +++ b/pandas/core/dtypes/api.py @@ -2,7 +2,6 @@ is_array_like, is_bool, is_bool_dtype, - is_categorical, is_categorical_dtype, is_complex, is_complex_dtype, @@ -45,7 +44,6 @@ "is_array_like", "is_bool", "is_bool_dtype", - "is_categorical", "is_categorical_dtype", "is_complex", "is_complex_dtype", diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index 61931b2a94490..3c2aa1f6bab5d 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -7,7 +7,6 @@ Any, Callable, ) -import warnings import numpy as np @@ -22,7 +21,6 @@ ArrayLike, DtypeObj, ) -from pandas.util._exceptions import find_stack_level from pandas.core.dtypes.base import _registry as registry from pandas.core.dtypes.dtypes import ( @@ -32,10 +30,7 @@ IntervalDtype, PeriodDtype, ) -from pandas.core.dtypes.generic import ( - ABCCategorical, - ABCIndex, -) +from pandas.core.dtypes.generic import ABCIndex from pandas.core.dtypes.inference import ( is_array_like, is_bool, @@ -275,47 +270,6 @@ def is_scipy_sparse(arr) -> bool: return _is_scipy_sparse(arr) -def is_categorical(arr) -> bool: - """ - Check whether an array-like is a Categorical instance. - - .. deprecated:: 1.1.0 - Use ``is_categorical_dtype`` instead. - - Parameters - ---------- - arr : array-like - The array-like to check. - - Returns - ------- - boolean - Whether or not the array-like is of a Categorical instance. - - Examples - -------- - >>> is_categorical([1, 2, 3]) - False - - Categoricals, Series Categoricals, and CategoricalIndex will return True. - - >>> cat = pd.Categorical([1, 2, 3]) - >>> is_categorical(cat) - True - >>> is_categorical(pd.Series(cat)) - True - >>> is_categorical(pd.CategoricalIndex([1, 2, 3])) - True - """ - warnings.warn( - "is_categorical is deprecated and will be removed in a future version. " - "Use is_categorical_dtype instead.", - FutureWarning, - stacklevel=find_stack_level(), - ) - return isinstance(arr, ABCCategorical) or is_categorical_dtype(arr) - - def is_datetime64_dtype(arr_or_dtype) -> bool: """ Check whether an array-like or dtype is of the datetime64 dtype. @@ -1772,7 +1726,6 @@ def is_all_strings(value: ArrayLike) -> bool: "is_array_like", "is_bool", "is_bool_dtype", - "is_categorical", "is_categorical_dtype", "is_complex", "is_complex_dtype", diff --git a/pandas/tests/api/test_types.py b/pandas/tests/api/test_types.py index 80eb9a2593f40..8c729fd19cbc7 100644 --- a/pandas/tests/api/test_types.py +++ b/pandas/tests/api/test_types.py @@ -10,7 +10,6 @@ class TestTypes(Base): allowed = [ "is_bool", "is_bool_dtype", - "is_categorical", "is_categorical_dtype", "is_complex", "is_complex_dtype", diff --git a/pandas/tests/dtypes/test_common.py b/pandas/tests/dtypes/test_common.py index 9f1ad2840ec87..589e2e04d668a 100644 --- a/pandas/tests/dtypes/test_common.py +++ b/pandas/tests/dtypes/test_common.py @@ -208,22 +208,6 @@ def test_is_scipy_sparse(): assert not com.is_scipy_sparse(SparseArray([1, 2, 3])) -def test_is_categorical(): - cat = pd.Categorical([1, 2, 3]) - with tm.assert_produces_warning(FutureWarning): - assert com.is_categorical(cat) - assert com.is_categorical(pd.Series(cat)) - assert com.is_categorical(pd.CategoricalIndex([1, 2, 3])) - - assert not com.is_categorical([1, 2, 3]) - - -def test_is_categorical_deprecation(): - # GH#33385 - with tm.assert_produces_warning(FutureWarning): - com.is_categorical([1, 2, 3]) - - def test_is_datetime64_dtype(): assert not com.is_datetime64_dtype(object) assert not com.is_datetime64_dtype([1, 2, 3]) diff --git a/pandas/tests/dtypes/test_dtypes.py b/pandas/tests/dtypes/test_dtypes.py index 7f6ec8b328c87..d054fb59d8561 100644 --- a/pandas/tests/dtypes/test_dtypes.py +++ b/pandas/tests/dtypes/test_dtypes.py @@ -9,7 +9,6 @@ from pandas.core.dtypes.base import _registry as registry from pandas.core.dtypes.common import ( is_bool_dtype, - is_categorical, is_categorical_dtype, is_datetime64_any_dtype, is_datetime64_dtype, @@ -179,13 +178,6 @@ def test_basic(self, dtype): assert is_categorical_dtype(s) assert not is_categorical_dtype(np.dtype("float64")) - with tm.assert_produces_warning(FutureWarning): - # GH#33385 deprecated - assert is_categorical(s.dtype) - assert is_categorical(s) - assert not is_categorical(np.dtype("float64")) - assert not is_categorical(1.0) - def test_tuple_categories(self): categories = [(1, "a"), (2, "b"), (3, "c")] result = CategoricalDtype(categories)