Pandas: Series - cov() function
Compute covariance with Pandas Series
The cov() function is used to compute covariance with Series, excluding missing values.
Syntax:
Series.cov(self, other, min_periods=None)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
other | Series with which to compute the covariance. | Series | Required |
min_periods | Minimum number of observations needed to have a valid result. | int | optional |
Returns: float
Covariance between Series and other normalized by N-1 (unbiased estimator).
Example:
Python-Pandas Code:
import numpy as np
import pandas as pd
s1 = pd.Series([0.90011105, 0.13494030, 0.62026040])
s2 = pd.Series([0.12630090, 0.26100470, 0.41111190])
s1.cov(s2)
Output:
-0.01832098497271333
Previous: Count null observations in Pandas series
Next: Cumulative maximum over a Pandas DataFrame or Series axis
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/pandas/series/series-cov.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics