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

Method idxmin

xarray/core/dataset.py:9198–9294  ·  view source on GitHub ↗

Return the coordinate label of the minimum value along a dimension. Returns a new `Dataset` 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:`~Data

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

Source from the content-addressed store, hash-verified

9196 return self._replace_with_new_dims(variables, indexes=indexes, attrs=attrs)
9197
9198 def idxmin(
9199 self,
9200 dim: Hashable | None = None,
9201 *,
9202 skipna: bool | None = None,
9203 fill_value: Any = xrdtypes.NA,
9204 keep_attrs: bool | None = None,
9205 ) -> Self:
9206 """Return the coordinate label of the minimum value along a dimension.
9207
9208 Returns a new `Dataset` named after the dimension with the values of
9209 the coordinate labels along that dimension corresponding to minimum
9210 values along that dimension.
9211
9212 In comparison to :py:meth:`~Dataset.argmin`, this returns the
9213 coordinate label while :py:meth:`~Dataset.argmin` returns the index.
9214
9215 Parameters
9216 ----------
9217 dim : Hashable, optional
9218 Dimension over which to apply `idxmin`. This is optional for 1D
9219 variables, but required for variables with 2 or more dimensions.
9220 skipna : bool or None, optional
9221 If True, skip missing values (as marked by NaN). By default, only
9222 skips missing values for ``float``, ``complex``, and ``object``
9223 dtypes; other dtypes either do not have a sentinel missing value
9224 (``int``) or ``skipna=True`` has not been implemented
9225 (``datetime64`` or ``timedelta64``).
9226 fill_value : Any, default: NaN
9227 Value to be filled in case all of the values along a dimension are
9228 null. By default this is NaN. The fill value and result are
9229 automatically converted to a compatible dtype if possible.
9230 Ignored if ``skipna`` is False.
9231 keep_attrs : bool or None, optional
9232 If True, the attributes (``attrs``) will be copied from the
9233 original object to the new one. If False, the new object
9234 will be returned without attributes.
9235
9236 Returns
9237 -------
9238 reduced : Dataset
9239 New `Dataset` object with `idxmin` applied to its data and the
9240 indicated dimension removed.
9241
9242 See Also
9243 --------
9244 DataArray.idxmin, Dataset.idxmax, Dataset.min, Dataset.argmin
9245
9246 Examples
9247 --------
9248 >>> array1 = xr.DataArray(
9249 ... [0, 2, 1, 0, -2], dims="x", coords={"x": ["a", "b", "c", "d", "e"]}
9250 ... )
9251 >>> array2 = xr.DataArray(
9252 ... [
9253 ... [2.0, 1.0, 2.0, 0.0, -2.0],
9254 ... [-4.0, np.nan, 2.0, np.nan, -2.0],
9255 ... [np.nan, np.nan, 1.0, np.nan, np.nan],

Callers 5

test_reduce_stringsMethod · 0.95
test_idxmin_chunkingFunction · 0.45
test_idxminMethod · 0.45
test_idxminMethod · 0.45
test_idxminMethod · 0.45

Calls 1

mapMethod · 0.95

Tested by 5

test_reduce_stringsMethod · 0.76
test_idxmin_chunkingFunction · 0.36
test_idxminMethod · 0.36
test_idxminMethod · 0.36
test_idxminMethod · 0.36