diff --git a/doc/source/reference/general_utility_functions.rst b/doc/source/reference/general_utility_functions.rst index 9c69770c0f1b78..0961acc43f301a 100644 --- a/doc/source/reference/general_utility_functions.rst +++ b/doc/source/reference/general_utility_functions.rst @@ -97,13 +97,11 @@ Scalar introspection api.types.is_bool api.types.is_categorical api.types.is_complex - api.types.is_datetimetz api.types.is_float api.types.is_hashable api.types.is_integer api.types.is_interval api.types.is_number - api.types.is_period api.types.is_re api.types.is_re_compilable api.types.is_scalar diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index db24be628dd672..d110b28754d3a8 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -325,6 +325,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more. - :meth:`DataFrame.to_records` no longer supports the argument "convert_datetime64" (:issue:`18902`) - Removed the previously deprecated ``IntervalIndex.from_intervals`` in favor of the :class:`IntervalIndex` constructor (:issue:`19263`) - Changed the default value for the "keep_tz" argument in :meth:`DatetimeIndex.to_series` to ``True`` (:issue:`23739`) +- Removed the previously deprecated :func:`api.types.is_period` and :func:`api.types.is_datetimetz` (:issue:`23917`) - Ability to read pickles containing :class:`Categorical` instances created with pre-0.16 version of pandas has been removed (:issue:`27538`) - Removed previously deprecated :func:`pandas.tseries.plotting.tsplot` (:issue:`18627`) - Removed the previously deprecated ``reduce`` and ``broadcast`` arguments from :meth:`DataFrame.apply` (:issue:`18577`) diff --git a/pandas/core/dtypes/api.py b/pandas/core/dtypes/api.py index 2b527e1fb58900..cb0912cbcf880d 100644 --- a/pandas/core/dtypes/api.py +++ b/pandas/core/dtypes/api.py @@ -12,7 +12,6 @@ is_datetime64_dtype, is_datetime64_ns_dtype, is_datetime64tz_dtype, - is_datetimetz, is_dict_like, is_dtype_equal, is_extension_array_dtype, @@ -32,7 +31,6 @@ is_number, is_numeric_dtype, is_object_dtype, - is_period, is_period_dtype, is_re, is_re_compilable, diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index dcc8a274492eef..783669688ea42c 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -375,56 +375,6 @@ def is_categorical(arr) -> bool: return isinstance(arr, ABCCategorical) or is_categorical_dtype(arr) -def is_datetimetz(arr) -> bool: - """ - Check whether an array-like is a datetime array-like with a timezone - component in its dtype. - - .. deprecated:: 0.24.0 - - Parameters - ---------- - arr : array-like - The array-like to check. - - Returns - ------- - boolean - Whether or not the array-like is a datetime array-like with a - timezone component in its dtype. - - Examples - -------- - >>> is_datetimetz([1, 2, 3]) - False - - Although the following examples are both DatetimeIndex objects, - the first one returns False because it has no timezone component - unlike the second one, which returns True. - - >>> is_datetimetz(pd.DatetimeIndex([1, 2, 3])) - False - >>> is_datetimetz(pd.DatetimeIndex([1, 2, 3], tz="US/Eastern")) - True - - The object need not be a DatetimeIndex object. It just needs to have - a dtype which has a timezone component. - - >>> dtype = DatetimeTZDtype("ns", tz="US/Eastern") - >>> s = pd.Series([], dtype=dtype) - >>> is_datetimetz(s) - True - """ - - warnings.warn( - "'is_datetimetz' is deprecated and will be removed in a " - "future version. Use 'is_datetime64tz_dtype' instead.", - FutureWarning, - stacklevel=2, - ) - return is_datetime64tz_dtype(arr) - - def is_offsetlike(arr_or_obj) -> bool: """ Check if obj or all elements of list-like is DateOffset @@ -456,43 +406,6 @@ def is_offsetlike(arr_or_obj) -> bool: return False -def is_period(arr) -> bool: - """ - Check whether an array-like is a periodical index. - - .. deprecated:: 0.24.0 - - Parameters - ---------- - arr : array-like - The array-like to check. - - Returns - ------- - boolean - Whether or not the array-like is a periodical index. - - Examples - -------- - >>> is_period([1, 2, 3]) - False - >>> is_period(pd.Index([1, 2, 3])) - False - >>> is_period(pd.PeriodIndex(["2017-01-01"], freq="D")) - True - """ - - warnings.warn( - "'is_period' is deprecated and will be removed in a future " - "version. Use 'is_period_dtype' or is_period_arraylike' " - "instead.", - FutureWarning, - stacklevel=2, - ) - - return isinstance(arr, ABCPeriodIndex) or is_period_arraylike(arr) - - def is_datetime64_dtype(arr_or_dtype) -> bool: """ Check whether an array-like or dtype is of the datetime64 dtype. diff --git a/pandas/tests/api/test_types.py b/pandas/tests/api/test_types.py index e9f68692a98639..97480502f192ce 100644 --- a/pandas/tests/api/test_types.py +++ b/pandas/tests/api/test_types.py @@ -50,7 +50,7 @@ class TestTypes(Base): "infer_dtype", "is_extension_array_dtype", ] - deprecated = ["is_period", "is_datetimetz", "is_extension_type"] + deprecated = ["is_extension_type"] dtypes = ["CategoricalDtype", "DatetimeTZDtype", "PeriodDtype", "IntervalDtype"] def test_types(self): diff --git a/pandas/tests/dtypes/test_common.py b/pandas/tests/dtypes/test_common.py index d8420673104d53..ae625ed8e389f3 100644 --- a/pandas/tests/dtypes/test_common.py +++ b/pandas/tests/dtypes/test_common.py @@ -207,25 +207,6 @@ def test_is_categorical(): assert not com.is_categorical([1, 2, 3]) -def test_is_datetimetz(): - with tm.assert_produces_warning(FutureWarning): - assert not com.is_datetimetz([1, 2, 3]) - assert not com.is_datetimetz(pd.DatetimeIndex([1, 2, 3])) - - assert com.is_datetimetz(pd.DatetimeIndex([1, 2, 3], tz="US/Eastern")) - - dtype = DatetimeTZDtype("ns", tz="US/Eastern") - s = pd.Series([], dtype=dtype) - assert com.is_datetimetz(s) - - -def test_is_period_deprecated(): - with tm.assert_produces_warning(FutureWarning): - assert not com.is_period([1, 2, 3]) - assert not com.is_period(pd.Index([1, 2, 3])) - assert com.is_period(pd.PeriodIndex(["2017-01-01"], freq="D")) - - 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 f4bf4c1fc83d94..fc896e6a9d348e 100644 --- a/pandas/tests/dtypes/test_dtypes.py +++ b/pandas/tests/dtypes/test_dtypes.py @@ -12,10 +12,8 @@ is_datetime64_dtype, is_datetime64_ns_dtype, is_datetime64tz_dtype, - is_datetimetz, is_dtype_equal, is_interval_dtype, - is_period, is_period_dtype, is_string_dtype, ) @@ -294,25 +292,15 @@ def test_basic(self): assert not is_datetime64tz_dtype(np.dtype("float64")) assert not is_datetime64tz_dtype(1.0) - with tm.assert_produces_warning(FutureWarning): - assert is_datetimetz(s) - assert is_datetimetz(s.dtype) - assert not is_datetimetz(np.dtype("float64")) - assert not is_datetimetz(1.0) - def test_dst(self): dr1 = date_range("2013-01-01", periods=3, tz="US/Eastern") s1 = Series(dr1, name="A") assert is_datetime64tz_dtype(s1) - with tm.assert_produces_warning(FutureWarning): - assert is_datetimetz(s1) dr2 = date_range("2013-08-01", periods=3, tz="US/Eastern") s2 = Series(dr2, name="A") assert is_datetime64tz_dtype(s2) - with tm.assert_produces_warning(FutureWarning): - assert is_datetimetz(s2) assert s1.dtype == s2.dtype @pytest.mark.parametrize("tz", ["UTC", "US/Eastern"]) @@ -457,22 +445,14 @@ def test_basic(self): assert is_period_dtype(pidx.dtype) assert is_period_dtype(pidx) - with tm.assert_produces_warning(FutureWarning): - assert is_period(pidx) s = Series(pidx, name="A") assert is_period_dtype(s.dtype) assert is_period_dtype(s) - with tm.assert_produces_warning(FutureWarning): - assert is_period(s) assert not is_period_dtype(np.dtype("float64")) assert not is_period_dtype(1.0) - with tm.assert_produces_warning(FutureWarning): - assert not is_period(np.dtype("float64")) - with tm.assert_produces_warning(FutureWarning): - assert not is_period(1.0) def test_empty(self): dt = PeriodDtype()