# xarray.computation.weighted.DatasetWeighted.sum_of_weights

#### DatasetWeighted.sum_of_weights(dim=None, , keep_attrs=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/computation/weighted.py#L453-L461)

Calculate the sum of weights, accounting for missing values in the data.

* **Parameters:**
  * **dim** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [sequence](https://docs.python.org/3/glossary.html#term-sequence) of [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *optional*) – Dimension(s) over which to sum the weights.
  * **keep_attrs** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *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`](xarray.Dataset.html.md#xarray.Dataset)) – New Dataset object with the sum of the weights over the given dimension.
