pyspark.pandas.Series.cov#

Series.cov(other, min_periods=None, ddof=1)[source]#

Compute covariance with Series, excluding missing values.

New in version 3.3.0.

Parameters
otherSeries

Series with which to compute the covariance.

min_periodsint, optional

Minimum number of observations needed to have a valid result.

ddofint, default 1

Delta degrees of freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.

New in version 3.4.0.

Returns
float

Covariance between Series and other

Examples

>>> from pyspark.pandas.config import set_option, reset_option
>>> s1 = ps.Series([0.90010907, 0.13484424, 0.62036035])
>>> s2 = ps.Series([0.12528585, 0.26962463, 0.51111198])
>>> with ps.option_context("compute.ops_on_diff_frames", True):
...     s1.cov(s2)
-0.016857...
>>> with ps.option_context("compute.ops_on_diff_frames", True):
...     s1.cov(s2, ddof=2)
-0.033715...