diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index ef514e7e89b57..4cca663296bf2 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -611,6 +611,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more. - Changed the default ``fill_value`` in :meth:`Categorical.take` from ``True`` to ``False`` (:issue:`20841`) - Changed the default value for the `raw` argument in :func:`Series.rolling().apply() `, :func:`DataFrame.rolling().apply() `, - :func:`Series.expanding().apply() `, and :func:`DataFrame.expanding().apply() ` to ``False`` (:issue:`20584`) +- Removed deprecated behavior of :meth:`Series.argmin` and :meth:`Series.argmax`, use :meth:`Series.idxmin` and :meth:`Series.idxmax` for the old behavior (:issue:`16955`) - Passing a tz-aware ``datetime.datetime`` or :class:`Timestamp` into the :class:`Timestamp` constructor with the ``tz`` argument now raises a ``ValueError`` (:issue:`23621`) - Removed the previously deprecated :attr:`Series.base`, :attr:`Index.base`, :attr:`Categorical.base`, :attr:`Series.flags`, :attr:`Index.flags`, :attr:`PeriodArray.flags`, :attr:`Series.strides`, :attr:`Index.strides`, :attr:`Series.itemsize`, :attr:`Index.itemsize`, :attr:`Series.data`, :attr:`Index.data` (:issue:`20721`) - Changed :meth:`Timedelta.resolution` to match the behavior of the standard library ``datetime.timedelta.resolution``, for the old behavior, use :meth:`Timedelta.resolution_string` (:issue:`26839`) diff --git a/pandas/core/series.py b/pandas/core/series.py index 9795412920efd..9d75025ebcb1a 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -13,7 +13,7 @@ from pandas._libs import index as libindex, lib, reshape, tslibs from pandas.compat.numpy import function as nv -from pandas.util._decorators import Appender, Substitution, deprecate +from pandas.util._decorators import Appender, Substitution from pandas.util._validators import validate_bool_kwarg, validate_percentile from pandas.core.dtypes.common import ( @@ -2001,36 +2001,6 @@ def idxmax(self, axis=0, skipna=True, *args, **kwargs): return np.nan return self.index[i] - # ndarray compat - argmin = deprecate( - "argmin", - idxmin, - "0.21.0", - msg=dedent( - """ - The current behaviour of 'Series.argmin' is deprecated, use 'idxmin' - instead. - The behavior of 'argmin' will be corrected to return the positional - minimum in the future. For now, use 'series.values.argmin' or - 'np.argmin(np.array(values))' to get the position of the minimum - row.""" - ), - ) - argmax = deprecate( - "argmax", - idxmax, - "0.21.0", - msg=dedent( - """ - The current behaviour of 'Series.argmax' is deprecated, use 'idxmax' - instead. - The behavior of 'argmax' will be corrected to return the positional - maximum in the future. For now, use 'series.values.argmax' or - 'np.argmax(np.array(values))' to get the position of the maximum - row.""" - ), - ) - def round(self, decimals=0, *args, **kwargs): """ Round each value in a Series to the given number of decimals. diff --git a/pandas/tests/reductions/test_reductions.py b/pandas/tests/reductions/test_reductions.py index 3f78a6ac4a778..d66472b1c2054 100644 --- a/pandas/tests/reductions/test_reductions.py +++ b/pandas/tests/reductions/test_reductions.py @@ -695,52 +695,40 @@ def test_empty_timeseries_reductions_return_nat(self): assert Series([], dtype=dtype).min(skipna=False) is pd.NaT assert Series([], dtype=dtype).max(skipna=False) is pd.NaT - def test_numpy_argmin_deprecated(self): + def test_numpy_argmin(self): # See GH#16830 data = np.arange(1, 11) s = Series(data, index=data) - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - # The deprecation of Series.argmin also causes a deprecation - # warning when calling np.argmin. This behavior is temporary - # until the implementation of Series.argmin is corrected. - result = np.argmin(s) + result = np.argmin(s) - assert result == 1 + expected = np.argmin(data) + assert result == expected - with tm.assert_produces_warning(FutureWarning): - # argmin is aliased to idxmin - result = s.argmin() + result = s.argmin() - assert result == 1 + assert result == expected - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - msg = "the 'out' parameter is not supported" - with pytest.raises(ValueError, match=msg): - np.argmin(s, out=data) + msg = "the 'out' parameter is not supported" + with pytest.raises(ValueError, match=msg): + np.argmin(s, out=data) - def test_numpy_argmax_deprecated(self): + def test_numpy_argmax(self): # See GH#16830 data = np.arange(1, 11) s = Series(data, index=data) - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - # The deprecation of Series.argmax also causes a deprecation - # warning when calling np.argmax. This behavior is temporary - # until the implementation of Series.argmax is corrected. - result = np.argmax(s) - assert result == 10 - - with tm.assert_produces_warning(FutureWarning): - # argmax is aliased to idxmax - result = s.argmax() - - assert result == 10 - - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - msg = "the 'out' parameter is not supported" - with pytest.raises(ValueError, match=msg): - np.argmax(s, out=data) + result = np.argmax(s) + expected = np.argmax(data) + assert result == expected + + result = s.argmax() + + assert result == expected + + msg = "the 'out' parameter is not supported" + with pytest.raises(ValueError, match=msg): + np.argmax(s, out=data) def test_idxmin(self): # test idxmin