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

CLN: convert argument in .take method #27171

Merged
merged 3 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -645,6 +645,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