🍾 Xarray is now 10 years old! 🎉

xarray.core.weighted.DatasetWeighted.sum

xarray.core.weighted.DatasetWeighted.sum#

DatasetWeighted.sum(dim=None, *, skipna=None, keep_attrs=None)[source]#

Reduce this Dataset’s data by a weighted sum along some dimension(s).

Parameters:
  • dim (Hashable or Iterable of Hashable, optional) – Dimension(s) over which to apply the weighted sum.

  • skipna (bool or None, optional) – If True, skip missing values (as marked by NaN). By default, only skips missing values for float dtypes; other dtypes either do not have a sentinel missing value (int) or skipna=True has not been implemented (object, datetime64 or timedelta64).

  • keep_attrs (bool or None, optional) – If True, the attributes (attrs) will be copied from the original object to the new one. If False (default), the new object will be returned without attributes.

Returns:

reduced (Dataset) – New Dataset object with weighted sum applied to its data and the indicated dimension(s) removed.

Notes

Returns 0 if the weights sum to 0.0 along the reduced dimension(s).