Tutorials References Menu

Pandas DataFrame cov() Method

❮ DataFrame Reference


Example

Find the covariance for each column in the DataFrame:

import pandas as pd

data = [[5, 6, 7], [2, 6, 9]]

df = pd.DataFrame(data)

print(df.cov())
Try it Yourself »

Definition and Usage

The cov() method finds the covariance of each column in a DataFrame.


Syntax

dataframe.cov(min_periods, ddof)

Parameters

The min_periods and ddof parameters are keyword arguments.

Parameter Value Description
min_periods Number Optional. Specifies the minimum number of observations required to return a good enough result
ddof Number Optional. Specifies the delta degrees of freedom. Default 1

 Return Value

A DataFrame object with the results.

This function does NOT make changes to the original DataFrame object.


❮ DataFrame Reference