Skip to content

Commit

Permalink
CLN: convert argument in .take method (#27171)
Browse files Browse the repository at this point in the history
* CLN: Convert argument in take

* Fix one test and whatsnew note
  • Loading branch information
mroeschke authored Jul 2, 2019
1 parent 527e714 commit 7ec7c9e
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 34 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
16 changes: 1 addition & 15 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down
9 changes: 2 additions & 7 deletions pandas/tests/frame/test_axis_select_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/series/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions pandas/tests/sparse/series/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 7ec7c9e

Please sign in to comment.