diff --git a/pandas/core/base.py b/pandas/core/base.py index f55d9f905945d..508582540e169 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -927,16 +927,17 @@ def max(self, axis=None, skipna=True, *args, **kwargs): nv.validate_max(args, kwargs) return nanops.nanmax(self._values, skipna=skipna) + @doc(op="max", oppose="min", value="largest") def argmax(self, axis=None, skipna=True, *args, **kwargs): """ - Return int position of the largest value in the Series. + Return int position of the {value} value in the Series. - If the maximum is achieved in multiple locations, + If the {op}imum is achieved in multiple locations, the first row position is returned. Parameters ---------- - axis : {None} + axis : {{None}} Dummy argument for consistency with Series. skipna : bool, default True Exclude NA/null values when showing the result. @@ -946,12 +947,13 @@ def argmax(self, axis=None, skipna=True, *args, **kwargs): Returns ------- int - Row position of the maximum values. + Row position of the {op}imum value. See Also -------- - numpy.ndarray.argmax : Equivalent method for numpy arrays. - Series.argmin : Similar method, but returning the minimum. + Series.arg{op} : Return position of the {op}imum value. + Series.arg{oppose} : Return position of the {oppose}imum value. + numpy.ndarray.arg{op} : Equivalent method for numpy arrays. Series.idxmax : Return index label of the maximum values. Series.idxmin : Return index label of the minimum values. @@ -959,8 +961,8 @@ def argmax(self, axis=None, skipna=True, *args, **kwargs): -------- Consider dataset containing cereal calories - >>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, - ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) + >>> s = pd.Series({{'Corn Flakes': 100.0, 'Almond Delight': 110.0, + ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}}) >>> s Corn Flakes 100.0 Almond Delight 110.0 @@ -970,8 +972,11 @@ def argmax(self, axis=None, skipna=True, *args, **kwargs): >>> s.argmax() 2 + >>> s.argmin() + 0 - The maximum cereal calories is in the third element, + The maximum cereal calories is the third element and + the minimum cereal calories is the first element, since series is zero-indexed. """ nv.validate_minmax_axis(axis) @@ -1019,25 +1024,8 @@ def min(self, axis=None, skipna=True, *args, **kwargs): nv.validate_min(args, kwargs) return nanops.nanmin(self._values, skipna=skipna) + @doc(argmax, op="min", oppose="max", value="smallest") def argmin(self, axis=None, skipna=True, *args, **kwargs): - """ - Return a ndarray of the minimum argument indexer. - - Parameters - ---------- - axis : {None} - Dummy argument for consistency with Series. - skipna : bool, default True - - Returns - ------- - numpy.ndarray - - See Also - -------- - numpy.ndarray.argmin : Return indices of the minimum values along - the given axis. - """ nv.validate_minmax_axis(axis) nv.validate_argmax_with_skipna(skipna, args, kwargs) return nanops.nanargmin(self._values, skipna=skipna)