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: Index.contains, DatetimeIndex.offset #30103

Merged
merged 8 commits into from
Dec 8, 2019
Merged
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
- Removed support for nested renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`18529`)
- Passing ``datetime64`` data to :class:`TimedeltaIndex` or ``timedelta64`` data to ``DatetimeIndex`` now raises ``TypeError`` (:issue:`23539`, :issue:`23937`)
- A tuple passed to :meth:`DataFrame.groupby` is now exclusively treated as a single key (:issue:`18314`)
- Removed the previously deprecated :meth:`Index.contains`, use ``key in index`` instead (:issue:`30103`)
- Removed the previously deprecated :attr:`RangeIndex._start`, :attr:`RangeIndex._stop`, :atttr:`RangeIndex._step` (:issue:`26581`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the min version of pyarrow that is ok here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the problem is in fastparquet; it fails in the most recent version 0.3.2

- Removed :meth:`Series.from_array` (:issue:`18258`)
- Removed :meth:`DataFrame.from_items` (:issue:`18458`)
- Removed :meth:`DataFrame.as_matrix`, :meth:`Series.as_matrix` (:issue:`18458`)
Expand Down
20 changes: 0 additions & 20 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3994,26 +3994,6 @@ def __contains__(self, key) -> bool:
except (OverflowError, TypeError, ValueError):
return False

def contains(self, key) -> bool:
"""
Return a boolean indicating whether the provided key is in the index.

.. deprecated:: 0.25.0
Use ``key in index`` instead of ``index.contains(key)``.

Returns
-------
bool
"""
warnings.warn(
"The 'contains' method is deprecated and will be removed in a "
"future version. Use 'key in index' instead of "
"'index.contains(key)'",
FutureWarning,
stacklevel=2,
)
return key in self

def __hash__(self):
raise TypeError(f"unhashable type: {repr(type(self).__name__)}")

Expand Down
28 changes: 0 additions & 28 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,34 +1147,6 @@ def slice_indexer(self, start=None, end=None, step=None, kind=None):

_has_same_tz = ea_passthrough(DatetimeArray._has_same_tz)

@property
def offset(self):
"""
get/set the frequency of the instance
"""
msg = (
"{cls}.offset has been deprecated and will be removed "
"in a future version; use {cls}.freq instead.".format(
cls=type(self).__name__
)
)
warnings.warn(msg, FutureWarning, stacklevel=2)
return self.freq

@offset.setter
def offset(self, value):
"""
get/set the frequency of the instance
"""
msg = (
"{cls}.offset has been deprecated and will be removed "
"in a future version; use {cls}.freq instead.".format(
cls=type(self).__name__
)
)
warnings.warn(msg, FutureWarning, stacklevel=2)
self._data.freq = value

def __getitem__(self, key):
result = self._data.__getitem__(key)
if is_scalar(result):
Expand Down
48 changes: 0 additions & 48 deletions pandas/core/indexes/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import operator
from sys import getsizeof
from typing import Optional, Union
import warnings

import numpy as np

Expand Down Expand Up @@ -215,44 +214,13 @@ def start(self):
# GH 25710
return self._range.start

@property
def _start(self):
"""
The value of the `start` parameter (``0`` if this was not supplied).

.. deprecated:: 0.25.0
Use ``start`` instead.
"""
warnings.warn(
self._deprecation_message.format("_start", "start"),
DeprecationWarning,
stacklevel=2,
)
return self.start

@cache_readonly
def stop(self):
"""
The value of the `stop` parameter.
"""
return self._range.stop

@property
def _stop(self):
"""
The value of the `stop` parameter.

.. deprecated:: 0.25.0
Use ``stop`` instead.
"""
# GH 25710
warnings.warn(
self._deprecation_message.format("_stop", "stop"),
DeprecationWarning,
stacklevel=2,
)
return self.stop

@cache_readonly
def step(self):
"""
Expand All @@ -261,22 +229,6 @@ def step(self):
# GH 25710
return self._range.step

@property
def _step(self):
"""
The value of the `step` parameter (``1`` if this was not supplied).

.. deprecated:: 0.25.0
Use ``step`` instead.
"""
# GH 25710
warnings.warn(
self._deprecation_message.format("_step", "step"),
DeprecationWarning,
stacklevel=2,
)
return self.step

@cache_readonly
def nbytes(self) -> int:
"""
Expand Down
12 changes: 0 additions & 12 deletions pandas/tests/indexes/datetimes/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,18 +437,6 @@ def test_freq_setter_errors(self):
with pytest.raises(ValueError, match="Invalid frequency"):
idx._data.freq = "foo"

def test_offset_deprecated(self):
# GH 20716
idx = pd.DatetimeIndex(["20180101", "20180102"])

# getter deprecated
with tm.assert_produces_warning(FutureWarning):
idx.offset

# setter deprecated
with tm.assert_produces_warning(FutureWarning):
idx.offset = BDay()


class TestBusinessDatetimeIndex:
def setup_method(self, method):
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2405,10 +2405,10 @@ def test_tab_complete_warning(self, ip):
with provisionalcompleter("ignore"):
list(ip.Completer.completions("idx.", 4))

def test_deprecated_contains(self, indices):
# deprecated for all types except IntervalIndex
warning = FutureWarning if not isinstance(indices, pd.IntervalIndex) else None
with tm.assert_produces_warning(warning):
def test_contains_method_removed(self, indices):
# GH#30103 method removed for all types except IntervalIndex
err = AttributeError if not isinstance(indices, pd.IntervalIndex) else None
with pytest.raises(err):
indices.contains(1)


Expand Down
15 changes: 0 additions & 15 deletions pandas/tests/indexes/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,6 @@ def test_start_stop_step_attrs(self, index, start, stop, step):
assert index.stop == stop
assert index.step == step

@pytest.mark.parametrize("attr_name", ["_start", "_stop", "_step"])
def test_deprecated_start_stop_step_attrs(self, attr_name):
# GH 26581
idx = self.create_index()
with tm.assert_produces_warning(DeprecationWarning):
getattr(idx, attr_name)

def test_copy(self):
i = RangeIndex(5, name="Foo")
i_copy = i.copy()
Expand Down Expand Up @@ -306,14 +299,6 @@ def test_cached_data(self):
91 in idx
assert idx._cached_data is None

with tm.assert_produces_warning(FutureWarning):
idx.contains(90)
assert idx._cached_data is None

with tm.assert_produces_warning(FutureWarning):
idx.contains(91)
assert idx._cached_data is None

idx.all()
assert idx._cached_data is None

Expand Down