# xarray.computation.weighted.DataArrayWeighted

### *class* xarray.computation.weighted.DataArrayWeighted(obj, weights)[[source]](https://github.com/pydata/xarray/blob/main/xarray/computation/weighted.py#L538-L554)

#### \_\_init_\_(obj, weights)[[source]](https://github.com/pydata/xarray/blob/main/xarray/computation/weighted.py#L149-L193)

Create a Weighted object

* **Parameters:**
  * **obj** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray) or [`Dataset`](xarray.Dataset.html.md#xarray.Dataset)) – Object over which the weighted reduction operation is applied.
  * **weights** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray)) – An array of weights associated with the values in the obj.
    Each value in the obj contributes to the reduction operation
    according to its associated weight.

### Notes

`weights` must be a `DataArray` and cannot contain missing values.
Missing values can be replaced by `weights.fillna(0)`.

### Methods

| [`__init__`](#xarray.computation.weighted.DataArrayWeighted.__init__)(obj, weights)                                                                                 | Create a Weighted object                                                           |
|---------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [`mean`](xarray.computation.weighted.DataArrayWeighted.mean.html.md#xarray.computation.weighted.DataArrayWeighted.mean)([dim, skipna, keep_attrs])                     | Reduce this Dataset's data by a weighted `mean` along some dimension(s).           |
| [`quantile`](xarray.computation.weighted.DataArrayWeighted.quantile.html.md#xarray.computation.weighted.DataArrayWeighted.quantile)(q, \*[, dim, keep_attrs, skipna])      | Apply a weighted `quantile` to this Dataset's data along some dimension(s).        |
| [`std`](xarray.computation.weighted.DataArrayWeighted.std.html.md#xarray.computation.weighted.DataArrayWeighted.std)([dim, skipna, keep_attrs])                       | Reduce this Dataset's data by a weighted `std` along some dimension(s).            |
| [`sum`](xarray.computation.weighted.DataArrayWeighted.sum.html.md#xarray.computation.weighted.DataArrayWeighted.sum)([dim, skipna, keep_attrs])                       | Reduce this Dataset's data by a weighted `sum` along some dimension(s).            |
| [`sum_of_squares`](xarray.computation.weighted.DataArrayWeighted.sum_of_squares.html.md#xarray.computation.weighted.DataArrayWeighted.sum_of_squares)([dim, skipna, keep_attrs]) | Reduce this Dataset's data by a weighted `sum_of_squares` along some dimension(s). |
| [`sum_of_weights`](xarray.computation.weighted.DataArrayWeighted.sum_of_weights.html.md#xarray.computation.weighted.DataArrayWeighted.sum_of_weights)([dim, keep_attrs])         | Calculate the sum of weights, accounting for missing values in the data.           |
| [`var`](xarray.computation.weighted.DataArrayWeighted.var.html.md#xarray.computation.weighted.DataArrayWeighted.var)([dim, skipna, keep_attrs])                       | Reduce this Dataset's data by a weighted `var` along some dimension(s).            |

### Attributes

| [`obj`](xarray.computation.weighted.DataArrayWeighted.obj.html.md#xarray.computation.weighted.DataArrayWeighted.obj)         |    |
|----------------------------------------------------------------------------------------------------------------|----|
| [`weights`](xarray.computation.weighted.DataArrayWeighted.weights.html.md#xarray.computation.weighted.DataArrayWeighted.weights) |    |
