Exponentially weighted moving correlation. `keep_attrs` is always True for this method. Drop attrs separately to remove attrs. Examples -------- >>> da = xr.DataArray([1, 1, 2, 2, 2], dims="x") >>> da.rolling_exp(x=2, window_type="span").corr(da.shi
(self, other: T_DataWithCoords)
| 256 | ).transpose(*dim_order) |
| 257 | |
| 258 | def corr(self, other: T_DataWithCoords) -> T_DataWithCoords: |
| 259 | """ |
| 260 | Exponentially weighted moving correlation. |
| 261 | |
| 262 | `keep_attrs` is always True for this method. Drop attrs separately to remove attrs. |
| 263 | |
| 264 | Examples |
| 265 | -------- |
| 266 | >>> da = xr.DataArray([1, 1, 2, 2, 2], dims="x") |
| 267 | >>> da.rolling_exp(x=2, window_type="span").corr(da.shift(x=1)) |
| 268 | <xarray.DataArray (x: 5)> Size: 40B |
| 269 | array([ nan, nan, nan, 0.4330127 , 0.48038446]) |
| 270 | Dimensions without coordinates: x |
| 271 | """ |
| 272 | |
| 273 | dim_order = self.obj.dims |
| 274 | import numbagg |
| 275 | |
| 276 | return apply_ufunc( |
| 277 | numbagg.move_exp_nancorr, |
| 278 | self.obj, |
| 279 | other, |
| 280 | input_core_dims=[[self.dim], [self.dim]], |
| 281 | kwargs=self.kwargs, |
| 282 | output_core_dims=[[self.dim]], |
| 283 | keep_attrs=True, |
| 284 | on_missing_core_dim="copy", |
| 285 | dask="parallelized", |
| 286 | ).transpose(*dim_order) |