Skip to content

Commit 52a63ab

Browse files
DOC: Fix errors in pandas.Series.argmax (#32019)
1 parent 9a8e83a commit 52a63ab

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

pandas/core/base.py

+32-4
Original file line numberDiff line numberDiff line change
@@ -927,22 +927,50 @@ def max(self, axis=None, skipna=True, *args, **kwargs):
927927

928928
def argmax(self, axis=None, skipna=True, *args, **kwargs):
929929
"""
930-
Return an ndarray of the maximum argument indexer.
930+
Return int position of the largest value in the Series.
931+
932+
If the maximum is achieved in multiple locations,
933+
the first row position is returned.
931934
932935
Parameters
933936
----------
934937
axis : {None}
935938
Dummy argument for consistency with Series.
936939
skipna : bool, default True
940+
Exclude NA/null values when showing the result.
941+
*args, **kwargs
942+
Additional arguments and keywords for compatibility with NumPy.
937943
938944
Returns
939945
-------
940-
numpy.ndarray
941-
Indices of the maximum values.
946+
int
947+
Row position of the maximum values.
942948
943949
See Also
944950
--------
945-
numpy.ndarray.argmax
951+
numpy.ndarray.argmax : Equivalent method for numpy arrays.
952+
Series.argmin : Similar method, but returning the minimum.
953+
Series.idxmax : Return index label of the maximum values.
954+
Series.idxmin : Return index label of the minimum values.
955+
956+
Examples
957+
--------
958+
Consider dataset containing cereal calories
959+
960+
>>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0,
961+
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0})
962+
>>> s
963+
Corn Flakes 100.0
964+
Almond Delight 110.0
965+
Cinnamon Toast Crunch 120.0
966+
Cocoa Puff 110.0
967+
dtype: float64
968+
969+
>>> s.argmax()
970+
2
971+
972+
The maximum cereal calories is in the third element,
973+
since series is zero-indexed.
946974
"""
947975
nv.validate_minmax_axis(axis)
948976
nv.validate_argmax_with_skipna(skipna, args, kwargs)

0 commit comments

Comments
 (0)