From 5bf2f8b0aca057c66e485670662a0ead3befa564 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Mon, 24 Oct 2022 00:21:58 +0200 Subject: [PATCH] DEP: Remove index.set_value --- doc/source/whatsnew/v2.0.0.rst | 2 +- pandas/core/indexes/base.py | 24 ------------------------ pandas/tests/indexes/test_base.py | 8 -------- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 6239ddf9442e7..94fccb95d9a11 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -190,7 +190,7 @@ Removal of prior version deprecations/changes - Removed deprecated :meth:`Categorical.replace`, use :meth:`Series.replace` instead (:issue:`44929`) - Removed the ``numeric_only`` keyword from :meth:`Categorical.min` and :meth:`Categorical.max` in favor of ``skipna`` (:issue:`48821`) - Removed :func:`is_extension_type` in favor of :func:`is_extension_array_dtype` (:issue:`29457`) -- Removed :meth:`Index.get_value` (:issue:`33907`) +- Removed :meth:`Index.get_value` and :meth:`Index.set_value` (:issue:`33907`, :issue:`28621`) - Remove :meth:`DataFrameGroupBy.pad` and :meth:`DataFrameGroupBy.backfill` (:issue:`45076`) - Remove ``numpy`` argument from :func:`read_json` (:issue:`30636`) - Removed the ``center`` keyword in :meth:`DataFrame.expanding` (:issue:`20647`) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 7d680688f4731..e89fa7806cba9 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -5905,30 +5905,6 @@ def _get_values_for_loc(self, series: Series, loc, key): return series.iloc[loc] - @final - def set_value(self, arr, key, value) -> None: - """ - Fast lookup of value from 1-dimensional ndarray. - - .. deprecated:: 1.0 - - Notes - ----- - Only use this if you know what you're doing. - """ - warnings.warn( - ( - "The 'set_value' method is deprecated, and " - "will be removed in a future version." - ), - FutureWarning, - stacklevel=find_stack_level(), - ) - loc = self._engine.get_loc(key) - if not can_hold_element(arr, value): - raise ValueError - arr[loc] = value - _index_shared_docs[ "get_indexer_non_unique" ] = """ diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index ff08b72b4a10d..bfe462cdf6c15 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -813,14 +813,6 @@ def test_is_monotonic_incomparable(self, attr): index = Index([5, datetime.now(), 7]) assert not getattr(index, attr) - def test_set_value_deprecated(self, simple_index): - # GH 28621 - idx = simple_index - arr = np.array([1, 2, 3]) - with tm.assert_produces_warning(FutureWarning): - idx.set_value(arr, idx[1], 80) - assert arr[1] == 80 - @pytest.mark.parametrize("values", [["foo", "bar", "quux"], {"foo", "bar", "quux"}]) @pytest.mark.parametrize( "index,expected",