Skip to content

Commit 7ec7c9e

Browse files
authored
CLN: convert argument in .take method (#27171)
* CLN: Convert argument in take * Fix one test and whatsnew note
1 parent 527e714 commit 7ec7c9e

File tree

5 files changed

+4
-34
lines changed

5 files changed

+4
-34
lines changed

doc/source/whatsnew/v0.25.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ Removal of prior version deprecations/changes
646646
- Removed the previously deprecated ``ordered`` and ``categories`` keyword arguments in ``astype`` (:issue:`17742`)
647647
- Removed the previously deprecated ``cdate_range`` (:issue:`17691`)
648648
- Removed the previously deprecated ``True`` option for the ``dropna`` keyword argument in :func:`SeriesGroupBy.nth` (:issue:`17493`)
649+
- Removed the previously deprecated ``convert`` keyword argument in :meth:`Series.take` and :meth:`DataFrame.take`(:issue:`17352`)
649650

650651
.. _whatsnew_0250.performance:
651652

pandas/core/generic.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -3365,7 +3365,7 @@ def _take(self, indices, axis=0, is_copy=True):
33653365

33663366
return result
33673367

3368-
def take(self, indices, axis=0, convert=None, is_copy=True, **kwargs):
3368+
def take(self, indices, axis=0, is_copy=True, **kwargs):
33693369
"""
33703370
Return the elements in the given *positional* indices along an axis.
33713371
@@ -3380,15 +3380,6 @@ def take(self, indices, axis=0, convert=None, is_copy=True, **kwargs):
33803380
axis : {0 or 'index', 1 or 'columns', None}, default 0
33813381
The axis on which to select elements. ``0`` means that we are
33823382
selecting rows, ``1`` means that we are selecting columns.
3383-
convert : bool, default True
3384-
Whether to convert negative indices into positive ones.
3385-
For example, ``-1`` would map to the ``len(axis) - 1``.
3386-
The conversions are similar to the behavior of indexing a
3387-
regular Python list.
3388-
3389-
.. deprecated:: 0.21.0
3390-
In the future, negative indices will always be converted.
3391-
33923383
is_copy : bool, default True
33933384
Whether to return a copy of the original object or not.
33943385
**kwargs
@@ -3449,11 +3440,6 @@ class max_speed
34493440
1 monkey mammal NaN
34503441
3 lion mammal 80.5
34513442
"""
3452-
if convert is not None:
3453-
msg = ("The 'convert' parameter is deprecated "
3454-
"and will be removed in a future version.")
3455-
warnings.warn(msg, FutureWarning, stacklevel=2)
3456-
34573443
nv.validate_take(tuple(), kwargs)
34583444
return self._take(indices, axis=axis, is_copy=is_copy)
34593445

pandas/tests/frame/test_axis_select_reindex.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -919,13 +919,8 @@ def test_take(self, float_frame):
919919
expected = df.reindex(df.index.take(order))
920920
assert_frame_equal(result, expected)
921921

922-
with tm.assert_produces_warning(FutureWarning):
923-
result = df.take(order, convert=True, axis=0)
924-
assert_frame_equal(result, expected)
925-
926-
with tm.assert_produces_warning(FutureWarning):
927-
result = df.take(order, convert=False, axis=0)
928-
assert_frame_equal(result, expected)
922+
result = df.take(order, axis=0)
923+
assert_frame_equal(result, expected)
929924

930925
# axis = 1
931926
result = df.take(order, axis=1)

pandas/tests/series/indexing/test_indexing.py

-3
Original file line numberDiff line numberDiff line change
@@ -801,9 +801,6 @@ def test_take():
801801
with pytest.raises(IndexError, match=msg.format(5)):
802802
s.take([2, 5])
803803

804-
with tm.assert_produces_warning(FutureWarning):
805-
s.take([-1, 3, 4], convert=False)
806-
807804

808805
def test_take_categorical():
809806
# https://github.com/pandas-dev/pandas/issues/20664

pandas/tests/sparse/series/test_series.py

-9
Original file line numberDiff line numberDiff line change
@@ -542,15 +542,6 @@ def _compare(idx):
542542
exp = pd.Series(np.repeat(nan, 5))
543543
tm.assert_series_equal(sp.take([0, 1, 2, 3, 4]), exp.to_sparse())
544544

545-
# multiple FutureWarnings, can't check stacklevel
546-
with tm.assert_produces_warning(FutureWarning,
547-
check_stacklevel=False):
548-
sp.take([1, 5], convert=True)
549-
550-
with tm.assert_produces_warning(FutureWarning,
551-
check_stacklevel=False):
552-
sp.take([1, 5], convert=False)
553-
554545
def test_numpy_take(self):
555546
sp = SparseSeries([1.0, 2.0, 3.0])
556547
indices = [1, 2]

0 commit comments

Comments
 (0)