MCPcopy Index your code
hub / github.com/pydata/xarray / idxmin

Method idxmin

xarray/core/dataarray.py:6009–6104  ·  view source on GitHub ↗

Return the coordinate label of the minimum value along a dimension. Returns a new `DataArray` named after the dimension with the values of the coordinate labels along that dimension corresponding to minimum values along that dimension. In comparison to :py:meth:`~Da

(
        self,
        dim: Hashable | None = None,
        *,
        skipna: bool | None = None,
        fill_value: Any = dtypes.NA,
        keep_attrs: bool | None = None,
    )

Source from the content-addressed store, hash-verified

6007 return self._from_temp_dataset(ds)
6008
6009 def idxmin(
6010 self,
6011 dim: Hashable | None = None,
6012 *,
6013 skipna: bool | None = None,
6014 fill_value: Any = dtypes.NA,
6015 keep_attrs: bool | None = None,
6016 ) -> Self:
6017 """Return the coordinate label of the minimum value along a dimension.
6018
6019 Returns a new `DataArray` named after the dimension with the values of
6020 the coordinate labels along that dimension corresponding to minimum
6021 values along that dimension.
6022
6023 In comparison to :py:meth:`~DataArray.argmin`, this returns the
6024 coordinate label while :py:meth:`~DataArray.argmin` returns the index.
6025
6026 Parameters
6027 ----------
6028 dim : str, optional
6029 Dimension over which to apply `idxmin`. This is optional for 1D
6030 arrays, but required for arrays with 2 or more dimensions.
6031 skipna : bool or None, default: None
6032 If True, skip missing values (as marked by NaN). By default, only
6033 skips missing values for ``float``, ``complex``, and ``object``
6034 dtypes; other dtypes either do not have a sentinel missing value
6035 (``int``) or ``skipna=True`` has not been implemented
6036 (``datetime64`` or ``timedelta64``).
6037 fill_value : Any, default: NaN
6038 Value to be filled in case all of the values along a dimension are
6039 null. By default this is NaN. The fill value and result are
6040 automatically converted to a compatible dtype if possible.
6041 Ignored if ``skipna`` is False.
6042 keep_attrs : bool or None, optional
6043 If True, the attributes (``attrs``) will be copied from the
6044 original object to the new one. If False, the new object
6045 will be returned without attributes.
6046
6047 Returns
6048 -------
6049 reduced : DataArray
6050 New `DataArray` object with `idxmin` applied to its data and the
6051 indicated dimension removed.
6052
6053 See Also
6054 --------
6055 Dataset.idxmin, DataArray.idxmax, DataArray.min, DataArray.argmin
6056
6057 Examples
6058 --------
6059 >>> array = xr.DataArray(
6060 ... [0, 2, 1, 0, -2], dims="x", coords={"x": ["a", "b", "c", "d", "e"]}
6061 ... )
6062 >>> array.min()
6063 <xarray.DataArray ()> Size: 8B
6064 array(-2)
6065 >>> array.argmin(...)
6066 {'x': <xarray.DataArray ()> Size: 8B

Callers 1

test_idxmin_chunkingFunction · 0.95

Calls 1

argminMethod · 0.45

Tested by 1

test_idxmin_chunkingFunction · 0.76