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: remove is_period, is_datetimetz #29744

Merged
merged 5 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions doc/source/reference/general_utility_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/dtypes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -32,7 +31,6 @@
is_number,
is_numeric_dtype,
is_object_dtype,
is_period,
is_period_dtype,
is_re,
is_re_compilable,
Expand Down
87 changes: 0 additions & 87 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/api/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
19 changes: 0 additions & 19 deletions pandas/tests/dtypes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
20 changes: 0 additions & 20 deletions pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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()
Expand Down