pandas.Index.argmax#
- Index.argmax(axis=None, skipna=True, *args, **kwargs)[源代码]#
返回 Series 中最大值的整数位置。
如果最大值在多个位置达到,则返回第一个行位置。
- Parameters:
- axis{ None }
未使用。参数是与 DataFrame 兼容性所必需的。
- <strong>skipna</strong>bool, default True
在显示结果时排除 NA/null 值。
- *args, **kwargs
用于与 NumPy 兼容的附加参数和关键字。
- Returns:
- int
最大值的行位置。
参见
Series.argmax返回最大值的索引位置。
Series.argmin返回最小值的索引位置。
numpy.ndarray.argmaxnumpy 数组的等效方法。
Series.idxmax返回最大值的索引标签。
Series.idxmin返回最小值的索引标签。
Examples
考虑包含麦片卡路里的数据集
>>> 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 Cinnamon Toast Crunch 120.0 Cocoa Puff 110.0 dtype: float64
>>> s.argmax() 2 >>> s.argmin() 0
麦片卡路里的最大值是第三个元素,最小值是第一个元素,因为 Series 是零索引的。