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 with
np.float64dtype.
See also
covSimilar method to calculate covariance.
numpy.corrcoefNumPy Pearson’s correlation calculation.
pandas.Series.expandingCalling expanding with Series data.
pandas.DataFrame.expandingCalling expanding with DataFrames.
pandas.Series.corrAggregating corr for Series.
pandas.DataFrame.corrAggregating 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
DataFrameinputs with pairwise set to True.Function will return
NaNfor 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.