MCPcopy
hub / github.com/pandas-dev/pandas / argmax

Method argmax

pandas/core/indexes/base.py:7624–7681  ·  view source on GitHub ↗

Return int position of the largest value in the Index. If the maximum is achieved in multiple locations, the first row position is returned. Parameters ---------- axis : None Unused. Parameter needed for compatibility with DataFrame.

(
        self, axis: AxisInt | None = None, skipna: bool = True, *args, **kwargs
    )

Source from the content-addressed store, hash-verified

7622 return super().argmin(skipna=skipna)
7623
7624 def argmax(
7625 self, axis: AxisInt | None = None, skipna: bool = True, *args, **kwargs
7626 ) -> int:
7627 """
7628 Return int position of the largest value in the Index.
7629
7630 If the maximum is achieved in multiple locations,
7631 the first row position is returned.
7632
7633 Parameters
7634 ----------
7635 axis : None
7636 Unused. Parameter needed for compatibility with DataFrame.
7637 skipna : bool, default True
7638 Exclude NA/null values. If the entire Series is NA, or if ``skipna=False``
7639 and there is an NA value, this method will raise a ``ValueError``.
7640 *args, **kwargs
7641 Additional arguments and keywords for compatibility with NumPy.
7642
7643 Returns
7644 -------
7645 int
7646 Row position of the maximum value.
7647
7648 See Also
7649 --------
7650 Series.argmax : Return position of the maximum value.
7651 Series.argmin : Return position of the minimum value.
7652 numpy.ndarray.argmax : Equivalent method for numpy arrays.
7653 Series.idxmax : Return index label of the maximum values.
7654 Series.idxmin : Return index label of the minimum values.
7655
7656 Examples
7657 --------
7658 Consider dataset containing cereal calories
7659
7660 >>> idx = pd.Index([100.0, 110.0, 120.0, 110.0])
7661 >>> idx
7662 Index([100.0, 110.0, 120.0, 110.0], dtype='float64')
7663
7664 >>> idx.argmax()
7665 np.int64(2)
7666 >>> idx.argmin()
7667 np.int64(0)
7668
7669 The maximum cereal calories is the third element and
7670 the minimum cereal calories is the first element,
7671 since index is zero-indexed.
7672 """
7673 nv.validate_argmax(args, kwargs)
7674 nv.validate_minmax_axis(axis)
7675
7676 if not self._is_multi and self.hasnans:
7677 if not skipna:
7678 raise ValueError("Encountered an NA value with skipna=False")
7679 elif self._isnan.all():
7680 raise ValueError("Encountered all NA values")
7681 return super().argmax(skipna=skipna)

Callers 4

test_argminmaxMethod · 0.95
asof_locsMethod · 0.45
get_locMethod · 0.45
_codes_and_uniquesMethod · 0.45

Calls 1

allMethod · 0.45

Tested by 1

test_argminmaxMethod · 0.76