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

Method sum

xarray/namedarray/_aggregations.py:463–544  ·  view source on GitHub ↗

Reduce this NamedArray's data by applying ``sum`` along some dimension(s). Parameters ---------- dim : str, Iterable of Hashable, "..." or None, default: None Name of dimension[s] along which to apply ``sum``. For e.g. ``dim="x"`` or ``dim=["

(
        self,
        dim: Dims = None,
        *,
        skipna: bool | None = None,
        min_count: int | None = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

461 )
462
463 def sum(
464 self,
465 dim: Dims = None,
466 *,
467 skipna: bool | None = None,
468 min_count: int | None = None,
469 **kwargs: Any,
470 ) -> Self:
471 """
472 Reduce this NamedArray's data by applying ``sum`` along some dimension(s).
473
474 Parameters
475 ----------
476 dim : str, Iterable of Hashable, "..." or None, default: None
477 Name of dimension[s] along which to apply ``sum``. For e.g. ``dim="x"``
478 or ``dim=["x", "y"]``. If "..." or None, will reduce over all dimensions.
479 skipna : bool or None, optional
480 If True, skip missing values (as marked by NaN). By default, only
481 skips missing values for float dtypes; other dtypes either do not
482 have a sentinel missing value (int) or ``skipna=True`` has not been
483 implemented (object, datetime64 or timedelta64).
484 min_count : int or None, optional
485 The required number of valid values to perform the operation. If
486 fewer than min_count non-NA values are present the result will be
487 NA. Only used if skipna is set to True or defaults to True for the
488 array's dtype. Changed in version 0.17.0: if specified on an integer
489 array and skipna=True, the result will be a float array.
490 **kwargs : Any
491 Additional keyword arguments passed on to the appropriate array
492 function for calculating ``sum`` on this object's data.
493 These could include dask-specific kwargs like ``split_every``.
494
495 Returns
496 -------
497 reduced : NamedArray
498 New NamedArray with ``sum`` applied to its data and the
499 indicated dimension(s) removed
500
501 See Also
502 --------
503 numpy.sum
504 dask.array.sum
505 Dataset.sum
506 DataArray.sum
507 :ref:`agg`
508 User guide on reduction or aggregation operations.
509
510 Notes
511 -----
512 Non-numeric variables will be removed prior to reducing.
513
514 Examples
515 --------
516 >>> from xarray.namedarray.core import NamedArray
517 >>> na = NamedArray("x", np.array([1, 2, 3, 0, 2, np.nan]))
518 >>> na
519 <xarray.NamedArray (x: 6)> Size: 48B
520 array([ 1., 2., 3., 0., 2., nan])

Callers

nothing calls this directly

Calls 1

reduceMethod · 0.95

Tested by

no test coverage detected