Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Series.idxmax#

Series.idxmax(axis=0,skipna=True,*args,**kwargs)[source]#

Return the row label of the maximum value.

If multiple values equal the maximum, the first row label with thatvalue is returned.

Parameters:
axis{0 or ‘index’}

Unused. Parameter needed for compatibility with DataFrame.

skipnabool, default True

Exclude NA/null values. If the entire Series is NA, the resultwill be NA.

*args, **kwargs

Additional arguments and keywords have no effect but might beaccepted for compatibility with NumPy.

Returns:
Index

Label of the maximum value.

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 indexlabel of the first occurrence of minimum of values.

Notes

This method is the Series version ofndarray.argmax. This methodreturns the label of the maximum, whilendarray.argmax returnsthe position. To get the position, useseries.values.argmax().

Examples

>>>s=pd.Series(data=[1,None,4,3,4],...index=['A','B','C','D','E'])>>>sA    1.0B    NaNC    4.0D    3.0E    4.0dtype: float64
>>>s.idxmax()'C'

Ifskipna is False and there is an NA value in the data,the function returnsnan.

>>>s.idxmax(skipna=False)nan

[8]ページ先頭

©2009-2025 Movatter.jp