Skip to content

Commit cdfcdf4

Browse files
farhanreynaldoFarhan Reynaldo Hutabaratsimonjayhawkins
authored andcommitted
DOC: Fix errors in pandas.Series.argmin (pandas-dev#32286)
Co-authored-by: Farhan Reynaldo Hutabarat <[email protected]> Co-authored-by: Simon Hawkins <[email protected]>
1 parent 435d8a6 commit cdfcdf4

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

pandas/core/base.py

+15-27
Original file line numberDiff line numberDiff line change
@@ -927,16 +927,17 @@ def max(self, axis=None, skipna=True, *args, **kwargs):
927927
nv.validate_max(args, kwargs)
928928
return nanops.nanmax(self._values, skipna=skipna)
929929

930+
@doc(op="max", oppose="min", value="largest")
930931
def argmax(self, axis=None, skipna=True, *args, **kwargs):
931932
"""
932-
Return int position of the largest value in the Series.
933+
Return int position of the {value} value in the Series.
933934
934-
If the maximum is achieved in multiple locations,
935+
If the {op}imum is achieved in multiple locations,
935936
the first row position is returned.
936937
937938
Parameters
938939
----------
939-
axis : {None}
940+
axis : {{None}}
940941
Dummy argument for consistency with Series.
941942
skipna : bool, default True
942943
Exclude NA/null values when showing the result.
@@ -946,21 +947,22 @@ def argmax(self, axis=None, skipna=True, *args, **kwargs):
946947
Returns
947948
-------
948949
int
949-
Row position of the maximum values.
950+
Row position of the {op}imum value.
950951
951952
See Also
952953
--------
953-
numpy.ndarray.argmax : Equivalent method for numpy arrays.
954-
Series.argmin : Similar method, but returning the minimum.
954+
Series.arg{op} : Return position of the {op}imum value.
955+
Series.arg{oppose} : Return position of the {oppose}imum value.
956+
numpy.ndarray.arg{op} : Equivalent method for numpy arrays.
955957
Series.idxmax : Return index label of the maximum values.
956958
Series.idxmin : Return index label of the minimum values.
957959
958960
Examples
959961
--------
960962
Consider dataset containing cereal calories
961963
962-
>>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0,
963-
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0})
964+
>>> s = pd.Series({{'Corn Flakes': 100.0, 'Almond Delight': 110.0,
965+
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}})
964966
>>> s
965967
Corn Flakes 100.0
966968
Almond Delight 110.0
@@ -970,8 +972,11 @@ def argmax(self, axis=None, skipna=True, *args, **kwargs):
970972
971973
>>> s.argmax()
972974
2
975+
>>> s.argmin()
976+
0
973977
974-
The maximum cereal calories is in the third element,
978+
The maximum cereal calories is the third element and
979+
the minimum cereal calories is the first element,
975980
since series is zero-indexed.
976981
"""
977982
nv.validate_minmax_axis(axis)
@@ -1019,25 +1024,8 @@ def min(self, axis=None, skipna=True, *args, **kwargs):
10191024
nv.validate_min(args, kwargs)
10201025
return nanops.nanmin(self._values, skipna=skipna)
10211026

1027+
@doc(argmax, op="min", oppose="max", value="smallest")
10221028
def argmin(self, axis=None, skipna=True, *args, **kwargs):
1023-
"""
1024-
Return a ndarray of the minimum argument indexer.
1025-
1026-
Parameters
1027-
----------
1028-
axis : {None}
1029-
Dummy argument for consistency with Series.
1030-
skipna : bool, default True
1031-
1032-
Returns
1033-
-------
1034-
numpy.ndarray
1035-
1036-
See Also
1037-
--------
1038-
numpy.ndarray.argmin : Return indices of the minimum values along
1039-
the given axis.
1040-
"""
10411029
nv.validate_minmax_axis(axis)
10421030
nv.validate_argmax_with_skipna(skipna, args, kwargs)
10431031
return nanops.nanargmin(self._values, skipna=skipna)

0 commit comments

Comments
 (0)