8000 CLN: Remove/deprecate unused/misleading dtype functions by jbrockmendel · Pull Request #23917 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

CLN: Remove/deprecate unused/misleading dtype functions #23917

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

Merged
merged 25 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
607f853
remove unused maybe_convert_scalar
jbrockmendel Nov 25, 2018
1e95d48
remove unused maybe_convert_string_to_object
jbrockmendel Nov 25, 2018
714c287
remove deprecated is_floating_dtype
jbrockmendel Nov 25, 2018
ba6ef3d
deprecate is_period
jbrockmendel Nov 25, 2018
a983755
deprecate is_datetimetz
jbrockmendel Nov 25, 2018
d7944b6
set stacklevel
jbrockmendel Nov 26, 2018
2c9b406
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Nov 26, 2018
34c4e91
remove unused is_timedelta_array and is_timedelta64_array
jbrockmendel Nov 26, 2018
8e86599
remove is_int_or_datetime_dtype
jbrockmendel Nov 26, 2018
0cf6239
GH reference
jbrockmendel Nov 26, 2018
8adda17
fixup typecheck
jbrockmendel Nov 26, 2018
fe02240
typo fixu[
jbrockmendel Nov 26, 2018
53d1de4
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Nov 26, 2018
e2f8669
8000 Address comments
jbrockmendel Nov 26, 2018
3daaabf
isort
jbrockmendel Nov 26, 2018
2566a18
dummy commit to force CI
jbrockmendel Nov 26, 2018
8342b97
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Nov 26, 2018
a7f7916
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Nov 27, 2018
6dda1be
separated conditions
jbrockmendel Nov 27, 2018
9c64633
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Nov 27, 2018
3d8752f
docstring fixup
jbrockmendel Nov 27, 2018
bb8a814
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Nov 27, 2018
71483b5
revert usage of needs_i8_conversion
jbrockmendel Nov 27, 2018
e0593bb
dummy commit to force CI
jbrockmendel Nov 27, 2018
5bdc157
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Nov 27, 2018
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
Prev Previous commit
Next Next commit
deprecate is_period
  • Loading branch information
jbrockmendel committed Nov 25, 2018
commit ba6ef3d8bd42341901b9e562cc71d746488b0882
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@ Deprecations
- The ``keep_tz=False`` option (the default) of the ``keep_tz`` keyword of
:meth:`DatetimeIndex.to_series` is deprecated (:issue:`17832`).
- Timezone converting a tz-aware ``datetime.datetime`` or :class:`Timestamp` with :class:`Timestamp` and the ``tz`` argument is now deprecated. Instead, use :meth:`Timestamp.tz_convert` (:issue:`23579`)
- :func:`pandas.dtypes.is_period` is deprecated in favor of `pandas.dtypes.is_period_dtype` (:issue:`????`)

.. _whatsnew_0240.deprecations.datetimelike_int_ops:

Expand Down
9 changes: 9 additions & 0 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
""" common type operations """
import warnings

import numpy as np

from pandas._libs import algos, lib
Expand Down Expand Up @@ -363,6 +365,8 @@ def is_period(arr):
"""
Check whether an array-like is a periodical index.

.. deprecated:: 0.24.0

Parameters
----------
arr : array-like
Expand All @@ -382,6 +386,11 @@ def is_period(arr):
True
"""

warnings.warn(FutureWarning,
"'is_period' is deprecated and will be removed in a future "
"version. Use 'is_period_dtype' or is_period_arraylike' "
"instead.")

# TODO: do we need this function?
# It seems like a repeat of is_period_arraylike.
return isinstance(arr, ABCPeriodIndex) or is_period_arraylike(arr)
Expand Down
8 changes: 5 additions & 3 deletions pandas/tests/dtypes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import pandas.core.dtypes.common as com
import pandas.util._test_decorators as td
import pandas.util.testing as tm


class TestPandasDtype(object):
Expand Down Expand Up @@ -172,9 +173,10 @@ def test_is_datetimetz():


def test_is_period():
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"))
with tm.assert_produces_warning(FutureWarning):
assert not com.is_period([1, 2, 3])
assert not com.is_period(pd.Index([1, 2, 3])) 8000
assert com.is_period(pd.PeriodIndex(["2017-01-01"], freq="D"))


def test_is_datetime64_dtype():
Expand Down
12 changes: 8 additions & 4 deletions pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,18 +378,22 @@ def test_basic(self):

assert is_period_dtype(pidx.dtype)
assert is_period_dtype(pidx)
assert is_period(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)
assert is_period(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)
assert not is_period(np.dtype('float64'))
assert not is_period(1.0)
with tm.assert_produces_warning(FutureWarning):
4C9A 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
0