diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 4ac737bb6b29a..01745ab0736d6 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -157,6 +157,7 @@ Removal of prior version deprecations/changes - Remove argument ``inplace`` from :meth:`MultiIndex.set_levels` and :meth:`MultiIndex.set_codes` (:issue:`35626`) - Disallow passing positional arguments to :meth:`MultiIndex.set_levels` and :meth:`MultiIndex.set_codes` (:issue:`41485`) - Removed argument ``try_cast`` from :meth:`DataFrame.mask`, :meth:`DataFrame.where`, :meth:`Series.mask` and :meth:`Series.where` (:issue:`38836`) +- Removed argument ``is_copy`` from :meth:`DataFrame.take` and :meth:`Series.take` (:issue:`30615`) - Disallow passing non-round floats to :class:`Timestamp` with ``unit="M"`` or ``unit="Y"`` (:issue:`47266`) - Removed deprecated :meth:`Timedelta.delta`, :meth:`Timedelta.is_populated`, and :attr:`Timedelta.freq` (:issue:`46430`, :issue:`46476`) - Removed the ``numeric_only`` keyword from :meth:`Categorical.min` and :meth:`Categorical.max` in favor of ``skipna`` (:issue:`48821`) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index a30b21d04ff59..5a554b417afe7 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3794,9 +3794,7 @@ def _clear_item_cache(self) -> None: # ---------------------------------------------------------------------- # Indexing Methods - def take( - self: NDFrameT, indices, axis: Axis = 0, is_copy: bool_t | None = None, **kwargs - ) -> NDFrameT: + def take(self: NDFrameT, indices, axis: Axis = 0, **kwargs) -> NDFrameT: """ Return the elements in the given *positional* indices along an axis. @@ -3812,13 +3810,6 @@ def take( The axis on which to select elements. ``0`` means that we are selecting rows, ``1`` means that we are selecting columns. For `Series` this parameter is unused and defaults to 0. - is_copy : bool - Before pandas 1.0, ``is_copy=False`` can be specified to ensure - that the return value is an actual copy. Starting with pandas 1.0, - ``take`` always returns a copy, and the keyword is therefore - deprecated. - - .. deprecated:: 1.0.0 **kwargs For compatibility with :meth:`numpy.take`. Has no effect on the output. @@ -3877,13 +3868,6 @@ class max_speed 1 monkey mammal NaN 3 lion mammal 80.5 """ - if is_copy is not None: - warnings.warn( - "is_copy is deprecated and will be removed in a future version. " - "'take' always returns a copy, so there is no need to specify this.", - FutureWarning, - stacklevel=find_stack_level(), - ) nv.validate_take((), kwargs) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 2bac228ef74a0..47452d885543e 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -856,12 +856,9 @@ def take( self, indices: TakeIndexer, axis: Axis = 0, - is_copy: bool | None = None, **kwargs, ) -> Series: - result = self._op_via_apply( - "take", indices=indices, axis=axis, is_copy=is_copy, **kwargs - ) + result = self._op_via_apply("take", indices=indices, axis=axis, **kwargs) return result @doc(Series.skew.__doc__) @@ -2254,12 +2251,9 @@ def take( self, indices: TakeIndexer, axis: Axis | None = 0, - is_copy: bool | None = None, **kwargs, ) -> DataFrame: - result = self._op_via_apply( - "take", indices=indices, axis=axis, is_copy=is_copy, **kwargs - ) + result = self._op_via_apply("take", indices=indices, axis=axis, **kwargs) return result @doc(DataFrame.skew.__doc__) diff --git a/pandas/core/series.py b/pandas/core/series.py index bf062ec53eec1..b7d12158fd909 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -889,16 +889,7 @@ def axes(self) -> list[Index]: # Indexing Methods @Appender(NDFrame.take.__doc__) - def take( - self, indices, axis: Axis = 0, is_copy: bool | None = None, **kwargs - ) -> Series: - if is_copy is not None: - warnings.warn( - "is_copy is deprecated and will be removed in a future version. " - "'take' always returns a copy, so there is no need to specify this.", - FutureWarning, - stacklevel=find_stack_level(), - ) + def take(self, indices, axis: Axis = 0, **kwargs) -> Series: nv.validate_take((), kwargs) indices = ensure_platform_int(indices) diff --git a/pandas/tests/generic/test_generic.py b/pandas/tests/generic/test_generic.py index 80d9bde784018..a6c516b51c6c5 100644 --- a/pandas/tests/generic/test_generic.py +++ b/pandas/tests/generic/test_generic.py @@ -429,21 +429,6 @@ def test_take_invalid_kwargs(self, frame_or_series): with pytest.raises(ValueError, match=msg): obj.take(indices, mode="clip") - @pytest.mark.parametrize("is_copy", [True, False]) - def test_depr_take_kwarg_is_copy(self, is_copy, frame_or_series): - # GH 27357 - obj = DataFrame({"A": [1, 2, 3]}) - obj = tm.get_obj(obj, frame_or_series) - - msg = ( - "is_copy is deprecated and will be removed in a future version. " - "'take' always returns a copy, so there is no need to specify this." - ) - with tm.assert_produces_warning(FutureWarning) as w: - obj.take([0, 1], is_copy=is_copy) - - assert w[0].message.args[0] == msg - def test_axis_classmethods(self, frame_or_series): box = frame_or_series obj = box(dtype=object)