snowflake.snowpark.modin.plugin.extensions.groupby_overrides.SeriesGroupBy.idxmin¶

SeriesGroupBy.idxmin(axis: Union[int, Literal['index', 'columns', 'rows']] = _NoDefault.no_default, skipna: bool = True, numeric_only: bool = False) → Series[source]¶

Return the index of the first occurrence of minimum over requested axis.

NA/null values are excluded based on skipna.

Parameters:
  • axis ({{0 or 'index', 1 or 'columns'}}, default None) –

    The axis to use. 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise. If axis is not provided, grouper’s axis is used.

    Snowpark pandas does not support axis=1, since it is deprecated in pandas.

    Deprecated since version 2.1.0: For axis=1, operate on the underlying object instead. Otherwise, the axis keyword is not necessary.

  • skipna (bool, default True) – Exclude NA/null values. If an entire row/column is NA, the result will be NA.

  • numeric_only (bool, default False) – Include only float, int or boolean data.

Returns:

Indexes of minima along the specified axis.

Return type:

Series

Raises:

ValueError – If the row/column is empty

See also

Series.idxmin

Return index of the minimum element.

Notes

This method is the DataFrame version of ndarray.argmin.

Examples

>>> small_df_data = [
...        ["lion", 78, 50, 50, 50],
...        ["tiger", -35, 12, -378, 1246],
...        ["giraffe", 54, -9, 67, -256],
...        ["hippopotamus", np.nan, -537, -47, -789],
...        ["tiger", 89, 2, 256, 246],
...        ["tiger", -325, 2, 2, 5],
...        ["tiger", 367, -367, 3, -6],
...        ["giraffe", 25, 6, 312, 6],
...        ["lion", -5, -5, -3, -4],
...        ["lion", 15, np.nan, 2, 12],
...        ["giraffe", 100, 200, 300, 400],
...        ["hippopotamus", -100, -300, -600, -200],
...        ["rhino", 26, 2, -45, 14],
...        ["rhino", -7, 63, 257, -257],
...        ["lion", 1, 2, 3, 4],
...        ["giraffe", -5, -6, -7, 8],
...        ["lion", 1234, 456, 78, np.nan],
... ]
Copy
>>> df = pd.DataFrame(
...     data=small_df_data,
...     columns=("species", "speed", "age", "weight", "height"),
...     index=list("abcdefghijklmnopq"),
... )
Copy

Group by axis=0, apply idxmax on axis=0

>>> df.groupby("species").idxmin(axis=0, skipna=True)  
             speed age weight height
species
giraffe          p   c      p      c
hippopotamus     l   d      l      d
lion             i   i      i      i
rhino            n   m      m      n
tiger            f   g      b      g
Copy
>>> df.groupby("species").idxmin(axis=0, skipna=False)  
             speed   age weight height
species
giraffe          p     c      p      c
hippopotamus  None     d      l      d
lion             i  None      i   None
rhino            n     m      m      n
tiger            f     g      b      g
Copy