pandas.core.window.expanding.Expanding.corr

Expanding.corr(other=None, pairwise=None, ddof=1, **kwargs)[source]

Calculate the expanding correlation.

Parameters
otherSeries or DataFrame, optional

If not supplied then will default to self and produce pairwise output.

pairwisebool, default None

If False then only matching columns between self and other will be used and the output will be a DataFrame. If True then all pairwise combinations will be calculated and the output will be a MultiIndexed DataFrame in the case of DataFrame inputs. In the case of missing elements, only complete pairwise observations will be used.

**kwargs

For NumPy compatibility and will not have an effect on the result.

Returns
Series or DataFrame

Return type is the same as the original object.

See also

cov

Similar method to calculate covariance.

numpy.corrcoef

NumPy Pearson’s correlation calculation.

pandas.Series.expanding

Calling expanding with Series data.

pandas.DataFrame.expanding

Calling expanding with DataFrames.

pandas.Series.corr

Aggregating corr for Series.

pandas.DataFrame.corr

Aggregating corr for DataFrame.

Notes

This function uses Pearson’s definition of correlation (https://en.wikipedia.org/wiki/Pearson_correlation_coefficient).

When other is not specified, the output will be self correlation (e.g. all 1’s), except for DataFrame inputs with pairwise set to True.

Function will return NaN for correlations of equal valued sequences; this is the result of a 0/0 division error.

When pairwise is set to False, only matching columns between self and other will be used.

When pairwise is set to True, the output will be a MultiIndex DataFrame with the original index on the first level, and the other DataFrame columns on the second level.

In the case of missing elements, only complete pairwise observations will be used.