Skip to content

pd.core.window.rolling.Rolling.corr

pandas.core.window.rolling.Rolling.corr(other=None, pairwise=None, ddof=1)

支持的参数

  • other: 数据框或系列(不能包含可为空的整数类型)
  • 必需
  • 如果使用 DataFrame 调用,other 必须是一个 DataFrame。如果使用 Series 调用,other 必须是一个 Series。

示例用法

>>> @bodo.jit
... def f(I):
...   df1 = pd.DataFrame({"A": [1,2,3,4,5,6,7]})
...   df2 = pd.DataFrame({"A": [1,2,3,4,-5,-6,-7]})
...   return df1.rolling(3).corr(df2)
        A
0       NaN
1       NaN
2  1.000000
3  1.000000
4 -0.810885
5 -0.907841
6 -1.000000