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

Method corr

xarray/computation/rolling_exp.py:258–286  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)

Callers 9

test_corr_only_dataarrayFunction · 0.80
test_lazy_corrcovFunction · 0.80
test_corrFunction · 0.80
test_covcorr_consistencyFunction · 0.80
test_corr_dtype_errorFunction · 0.80
test_bilinear_cov_corrFunction · 0.80
test_corrMethod · 0.80

Calls 2

apply_ufuncFunction · 0.90
transposeMethod · 0.45

Tested by 9

test_corr_only_dataarrayFunction · 0.64
test_lazy_corrcovFunction · 0.64
test_corrFunction · 0.64
test_covcorr_consistencyFunction · 0.64
test_corr_dtype_errorFunction · 0.64
test_bilinear_cov_corrFunction · 0.64
test_corrMethod · 0.64