MCPcopy
hub / github.com/pydata/xarray / argmax

Method argmax

xarray/core/dataset.py:9497–9588  ·  view source on GitHub ↗

Indices of the maxima of the member variables. If there are multiple maxima, the indices of the first one found will be returned. Parameters ---------- dim : str, optional The dimension over which to find the maximum. By default, finds maximum ov

(self, dim: Hashable | None = None, **kwargs)

Source from the content-addressed store, hash-verified

9495 )
9496
9497 def argmax(self, dim: Hashable | None = None, **kwargs) -> Self:
9498 """Indices of the maxima of the member variables.
9499
9500 If there are multiple maxima, the indices of the first one found will be
9501 returned.
9502
9503 Parameters
9504 ----------
9505 dim : str, optional
9506 The dimension over which to find the maximum. By default, finds maximum over
9507 all dimensions - for now returning an int for backward compatibility, but
9508 this is deprecated, in future will be an error, since DataArray.argmax will
9509 return a dict with indices for all dimensions, which does not make sense for
9510 a Dataset.
9511 keep_attrs : bool, optional
9512 If True, the attributes (`attrs`) will be copied from the original
9513 object to the new one. If False (default), the new object will be
9514 returned without attributes.
9515 skipna : bool, optional
9516 If True, skip missing values (as marked by NaN). By default, only
9517 skips missing values for float dtypes; other dtypes either do not
9518 have a sentinel missing value (int) or skipna=True has not been
9519 implemented (object, datetime64 or timedelta64).
9520
9521 Returns
9522 -------
9523 result : Dataset
9524
9525 Examples
9526 --------
9527
9528 >>> dataset = xr.Dataset(
9529 ... {
9530 ... "math_scores": (
9531 ... ["student", "test"],
9532 ... [[90, 85, 92], [78, 80, 85], [95, 92, 98]],
9533 ... ),
9534 ... "english_scores": (
9535 ... ["student", "test"],
9536 ... [[88, 90, 92], [75, 82, 79], [93, 96, 91]],
9537 ... ),
9538 ... },
9539 ... coords={
9540 ... "student": ["Alice", "Bob", "Charlie"],
9541 ... "test": ["Test 1", "Test 2", "Test 3"],
9542 ... },
9543 ... )
9544
9545 # Indices of the maximum values along the 'student' dimension are calculated
9546
9547 >>> argmax_indices = dataset.argmax(dim="test")
9548
9549 >>> argmax_indices
9550 <xarray.Dataset> Size: 132B
9551 Dimensions: (student: 3)
9552 Coordinates:
9553 * student (student) <U7 84B 'Alice' 'Bob' 'Charlie'
9554 Data variables:

Callers 9

test_reduce_stringsMethod · 0.95
nanfirstFunction · 0.45
nanlastFunction · 0.45
_decompose_outer_indexerFunction · 0.45
format_array_flatFunction · 0.45
test_reduceMethod · 0.45
test_argmax_dimMethod · 0.45
test_argmaxMethod · 0.45

Calls 1

reduceMethod · 0.95

Tested by 4

test_reduce_stringsMethod · 0.76
test_reduceMethod · 0.36
test_argmax_dimMethod · 0.36
test_argmaxMethod · 0.36