diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index fa8519c89b67f..2030bb4d974c3 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -646,6 +646,7 @@ Removal of prior version deprecations/changes - Removed the previously deprecated ``ordered`` and ``categories`` keyword arguments in ``astype`` (:issue:`17742`) - Removed the previously deprecated ``cdate_range`` (:issue:`17691`) - Removed the previously deprecated ``True`` option for the ``dropna`` keyword argument in :func:`SeriesGroupBy.nth` (:issue:`17493`) +- Removed the previously deprecated ``convert`` keyword argument in :meth:`Series.take` and :meth:`DataFrame.take`(:issue:`17352`) .. _whatsnew_0250.performance: diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 380af8930f344..822428c6787be 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3365,7 +3365,7 @@ def _take(self, indices, axis=0, is_copy=True): return result - def take(self, indices, axis=0, convert=None, is_copy=True, **kwargs): + def take(self, indices, axis=0, is_copy=True, **kwargs): """ Return the elements in the given *positional* indices along an axis. @@ -3380,15 +3380,6 @@ def take(self, indices, axis=0, convert=None, is_copy=True, **kwargs): axis : {0 or 'index', 1 or 'columns', None}, default 0 The axis on which to select elements. ``0`` means that we are selecting rows, ``1`` means that we are selecting columns. - convert : bool, default True - Whether to convert negative indices into positive ones. - For example, ``-1`` would map to the ``len(axis) - 1``. - The conversions are similar to the behavior of indexing a - regular Python list. - - .. deprecated:: 0.21.0 - In the future, negative indices will always be converted. - is_copy : bool, default True Whether to return a copy of the original object or not. **kwargs @@ -3449,11 +3440,6 @@ class max_speed 1 monkey mammal NaN 3 lion mammal 80.5 """ - if convert is not None: - msg = ("The 'convert' parameter is deprecated " - "and will be removed in a future version.") - warnings.warn(msg, FutureWarning, stacklevel=2) - nv.validate_take(tuple(), kwargs) return self._take(indices, axis=axis, is_copy=is_copy) diff --git a/pandas/tests/frame/test_axis_select_reindex.py b/pandas/tests/frame/test_axis_select_reindex.py index 18c95beb62a13..12ac373aa8f60 100644 --- a/pandas/tests/frame/test_axis_select_reindex.py +++ b/pandas/tests/frame/test_axis_select_reindex.py @@ -919,13 +919,8 @@ def test_take(self, float_frame): expected = df.reindex(df.index.take(order)) assert_frame_equal(result, expected) - with tm.assert_produces_warning(FutureWarning): - result = df.take(order, convert=True, axis=0) - assert_frame_equal(result, expected) - - with tm.assert_produces_warning(FutureWarning): - result = df.take(order, convert=False, axis=0) - assert_frame_equal(result, expected) + result = df.take(order, axis=0) + assert_frame_equal(result, expected) # axis = 1 result = df.take(order, axis=1) diff --git a/pandas/tests/series/indexing/test_indexing.py b/pandas/tests/series/indexing/test_indexing.py index 702e22b6741e4..d794b4aca82e6 100644 --- a/pandas/tests/series/indexing/test_indexing.py +++ b/pandas/tests/series/indexing/test_indexing.py @@ -801,9 +801,6 @@ def test_take(): with pytest.raises(IndexError, match=msg.format(5)): s.take([2, 5]) - with tm.assert_produces_warning(FutureWarning): - s.take([-1, 3, 4], convert=False) - def test_take_categorical(): # https://github.com/pandas-dev/pandas/issues/20664 diff --git a/pandas/tests/sparse/series/test_series.py b/pandas/tests/sparse/series/test_series.py index 290e0203567db..2abd63281c4fe 100644 --- a/pandas/tests/sparse/series/test_series.py +++ b/pandas/tests/sparse/series/test_series.py @@ -542,15 +542,6 @@ def _compare(idx): exp = pd.Series(np.repeat(nan, 5)) tm.assert_series_equal(sp.take([0, 1, 2, 3, 4]), exp.to_sparse()) - # multiple FutureWarnings, can't check stacklevel - with tm.assert_produces_warning(FutureWarning, - check_stacklevel=False): - sp.take([1, 5], convert=True) - - with tm.assert_produces_warning(FutureWarning, - check_stacklevel=False): - sp.take([1, 5], convert=False) - def test_numpy_take(self): sp = SparseSeries([1.0, 2.0, 3.0]) indices = [1, 2]