Skip to content

Commit 06164dd

Browse files
jbrockmendelproost
authored andcommitted
DEPR: remove is_period, is_datetimetz (pandas-dev#29744)
1 parent cb001f2 commit 06164dd

File tree

7 files changed

+2
-131
lines changed

7 files changed

+2
-131
lines changed

doc/source/reference/general_utility_functions.rst

-2
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,11 @@ Scalar introspection
9797
api.types.is_bool
9898
api.types.is_categorical
9999
api.types.is_complex
100-
api.types.is_datetimetz
101100
api.types.is_float
102101
api.types.is_hashable
103102
api.types.is_integer
104103
api.types.is_interval
105104
api.types.is_number
106-
api.types.is_period
107105
api.types.is_re
108106
api.types.is_re_compilable
109107
api.types.is_scalar

doc/source/whatsnew/v1.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
325325
- :meth:`DataFrame.to_records` no longer supports the argument "convert_datetime64" (:issue:`18902`)
326326
- Removed the previously deprecated ``IntervalIndex.from_intervals`` in favor of the :class:`IntervalIndex` constructor (:issue:`19263`)
327327
- Changed the default value for the "keep_tz" argument in :meth:`DatetimeIndex.to_series` to ``True`` (:issue:`23739`)
328+
- Removed the previously deprecated :func:`api.types.is_period` and :func:`api.types.is_datetimetz` (:issue:`23917`)
328329
- Ability to read pickles containing :class:`Categorical` instances created with pre-0.16 version of pandas has been removed (:issue:`27538`)
329330
- Removed previously deprecated :func:`pandas.tseries.plotting.tsplot` (:issue:`18627`)
330331
- Removed the previously deprecated ``reduce`` and ``broadcast`` arguments from :meth:`DataFrame.apply` (:issue:`18577`)

pandas/core/dtypes/api.py

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
is_datetime64_dtype,
1313
is_datetime64_ns_dtype,
1414
is_datetime64tz_dtype,
15-
is_datetimetz,
1615
is_dict_like,
1716
is_dtype_equal,
1817
is_extension_array_dtype,
@@ -32,7 +31,6 @@
3231
is_number,
3332
is_numeric_dtype,
3433
is_object_dtype,
35-
is_period,
3634
is_period_dtype,
3735
is_re,
3836
is_re_compilable,

pandas/core/dtypes/common.py

-87
Original file line numberDiff line numberDiff line change
@@ -375,56 +375,6 @@ def is_categorical(arr) -> bool:
375375
return isinstance(arr, ABCCategorical) or is_categorical_dtype(arr)
376376

377377

378-
def is_datetimetz(arr) -> bool:
379-
"""
380-
Check whether an array-like is a datetime array-like with a timezone
381-
component in its dtype.
382-
383-
.. deprecated:: 0.24.0
384-
385-
Parameters
386-
----------
387-
arr : array-like
388-
The array-like to check.
389-
390-
Returns
391-
-------
392-
boolean
393-
Whether or not the array-like is a datetime array-like with a
394-
timezone component in its dtype.
395-
396-
Examples
397-
--------
398-
>>> is_datetimetz([1, 2, 3])
399-
False
400-
401-
Although the following examples are both DatetimeIndex objects,
402-
the first one returns False because it has no timezone component
403-
unlike the second one, which returns True.
404-
405-
>>> is_datetimetz(pd.DatetimeIndex([1, 2, 3]))
406-
False
407-
>>> is_datetimetz(pd.DatetimeIndex([1, 2, 3], tz="US/Eastern"))
408-
True
409-
410-
The object need not be a DatetimeIndex object. It just needs to have
411-
a dtype which has a timezone component.
412-
413-
>>> dtype = DatetimeTZDtype("ns", tz="US/Eastern")
414-
>>> s = pd.Series([], dtype=dtype)
415-
>>> is_datetimetz(s)
416-
True
417-
"""
418-
419-
warnings.warn(
420-
"'is_datetimetz' is deprecated and will be removed in a "
421-
"future version. Use 'is_datetime64tz_dtype' instead.",
422-
FutureWarning,
423-
stacklevel=2,
424-
)
425-
return is_datetime64tz_dtype(arr)
426-
427-
428378
def is_offsetlike(arr_or_obj) -> bool:
429379
"""
430380
Check if obj or all elements of list-like is DateOffset
@@ -456,43 +406,6 @@ def is_offsetlike(arr_or_obj) -> bool:
456406
return False
457407

458408

459-
def is_period(arr) -> bool:
460-
"""
461-
Check whether an array-like is a periodical index.
462-
463-
.. deprecated:: 0.24.0
464-
465-
Parameters
466-
----------
467-
arr : array-like
468-
The array-like to check.
469-
470-
Returns
471-
-------
472-
boolean
473-
Whether or not the array-like is a periodical index.
474-
475-
Examples
476-
--------
477-
>>> is_period([1, 2, 3])
478-
False
479-
>>> is_period(pd.Index([1, 2, 3]))
480-
False
481-
>>> is_period(pd.PeriodIndex(["2017-01-01"], freq="D"))
482-
True
483-
"""
484-
485-
warnings.warn(
486-
"'is_period' is deprecated and will be removed in a future "
487-
"version. Use 'is_period_dtype' or is_period_arraylike' "
488-
"instead.",
489-
FutureWarning,
490-
stacklevel=2,
491-
)
492-
493-
return isinstance(arr, ABCPeriodIndex) or is_period_arraylike(arr)
494-
495-
496409
def is_datetime64_dtype(arr_or_dtype) -> bool:
497410
"""
498411
Check whether an array-like or dtype is of the datetime64 dtype.

pandas/tests/api/test_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class TestTypes(Base):
5050
"infer_dtype",
5151
"is_extension_array_dtype",
5252
]
53-
deprecated = ["is_period", "is_datetimetz", "is_extension_type"]
53+
deprecated = ["is_extension_type"]
5454
dtypes = ["CategoricalDtype", "DatetimeTZDtype", "PeriodDtype", "IntervalDtype"]
5555

5656
def test_types(self):

pandas/tests/dtypes/test_common.py

-19
Original file line numberDiff line numberDiff line change
@@ -207,25 +207,6 @@ def test_is_categorical():
207207
assert not com.is_categorical([1, 2, 3])
208208

209209

210-
def test_is_datetimetz():
211-
with tm.assert_produces_warning(FutureWarning):
212-
assert not com.is_datetimetz([1, 2, 3])
213-
assert not com.is_datetimetz(pd.DatetimeIndex([1, 2, 3]))
214-
215-
assert com.is_datetimetz(pd.DatetimeIndex([1, 2, 3], tz="US/Eastern"))
216-
217-
dtype = DatetimeTZDtype("ns", tz="US/Eastern")
218-
s = pd.Series([], dtype=dtype)
219-
assert com.is_datetimetz(s)
220-
221-
222-
def test_is_period_deprecated():
223-
with tm.assert_produces_warning(FutureWarning):
224-
assert not com.is_period([1, 2, 3])
225-
assert not com.is_period(pd.Index([1, 2, 3]))
226-
assert com.is_period(pd.PeriodIndex(["2017-01-01"], freq="D"))
227-
228-
229210
def test_is_datetime64_dtype():
230211
assert not com.is_datetime64_dtype(object)
231212
assert not com.is_datetime64_dtype([1, 2, 3])

pandas/tests/dtypes/test_dtypes.py

-20
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
is_datetime64_dtype,
1313
is_datetime64_ns_dtype,
1414
is_datetime64tz_dtype,
15-
is_datetimetz,
1615
is_dtype_equal,
1716
is_interval_dtype,
18-
is_period,
1917
is_period_dtype,
2018
is_string_dtype,
2119
)
@@ -294,25 +292,15 @@ def test_basic(self):
294292
assert not is_datetime64tz_dtype(np.dtype("float64"))
295293
assert not is_datetime64tz_dtype(1.0)
296294

297-
with tm.assert_produces_warning(FutureWarning):
298-
assert is_datetimetz(s)
299-
assert is_datetimetz(s.dtype)
300-
assert not is_datetimetz(np.dtype("float64"))
301-
assert not is_datetimetz(1.0)
302-
303295
def test_dst(self):
304296

305297
dr1 = date_range("2013-01-01", periods=3, tz="US/Eastern")
306298
s1 = Series(dr1, name="A")
307299
assert is_datetime64tz_dtype(s1)
308-
with tm.assert_produces_warning(FutureWarning):
309-
assert is_datetimetz(s1)
310300

311301
dr2 = date_range("2013-08-01", periods=3, tz="US/Eastern")
312302
s2 = Series(dr2, name="A")
313303
assert is_datetime64tz_dtype(s2)
314-
with tm.assert_produces_warning(FutureWarning):
315-
assert is_datetimetz(s2)
316304
assert s1.dtype == s2.dtype
317305

318306
@pytest.mark.parametrize("tz", ["UTC", "US/Eastern"])
@@ -457,22 +445,14 @@ def test_basic(self):
457445

458446
assert is_period_dtype(pidx.dtype)
459447
assert is_period_dtype(pidx)
460-
with tm.assert_produces_warning(FutureWarning):
461-
assert is_period(pidx)
462448

463449
s = Series(pidx, name="A")
464450

465451
assert is_period_dtype(s.dtype)
466452
assert is_period_dtype(s)
467-
with tm.assert_produces_warning(FutureWarning):
468-
assert is_period(s)
469453

470454
assert not is_period_dtype(np.dtype("float64"))
471455
assert not is_period_dtype(1.0)
472-
with tm.assert_produces_warning(FutureWarning):
473-
assert not is_period(np.dtype("float64"))
474-
with tm.assert_produces_warning(FutureWarning):
475-
assert not is_period(1.0)
476456

477457
def test_empty(self):
478458
dt = PeriodDtype()

0 commit comments

Comments
 (0)