pandas.Series.argmax¶
-
Series.
argmax
(axis=0, skipna=True, *args, **kwargs)[source]¶ -
Deprecated since version 0.21.0:
- ‘argmax’ is deprecated, use ‘idxmax’ instead. The behavior of ‘argmax’
- will be corrected to return the positional maximum in the future. Use ‘series.values.argmax’ to get the position of the maximum now.
Return the row label of the maximum value.
If multiple values equal the maximum, the first row label with that value is returned.
Parameters: skipna : boolean, default True
Exclude NA/null values. If the entire Series is NA, the result will be NA.
axis : int, default 0
For compatibility with DataFrame.idxmax. Redundant for application on Series.
*args, **kwargs
Additional keywors have no effect but might be accepted for compatibility with NumPy.
Returns: - idxmax : Index of maximum of values.
Raises: ValueError
If the Series is empty.
See also
numpy.argmax
- Return indices of the maximum values along the given axis.
DataFrame.idxmax
- Return index of first occurrence of maximum over requested axis.
Series.idxmin
- Return index label of the first occurrence of minimum of values.
Notes
This method is the Series version of
ndarray.argmax
. This method returns the label of the maximum, whilendarray.argmax
returns the position. To get the position, useseries.values.argmax()
.Examples
>>> s = pd.Series(data=[1, None, 4, 3, 4], ... index=['A', 'B', 'C', 'D', 'E']) >>> s A 1.0 B NaN C 4.0 D 3.0 E 4.0 dtype: float64
>>> s.idxmax() 'C'
If skipna is False and there is an NA value in the data, the function returns
nan
.>>> s.idxmax(skipna=False) nan