python - 如何将 pd.DataFrame.rolling.corr() 与 Kendall 的 Tau 或 Spearman 一起使用
问题描述
就像标题所暗示的那样,是否有一种内置方法可以在 df.rolling() 之上执行替代相关方法?我知道 df.rolling.apply(),但希望有一些内置的东西。
# Example
df = pd.DataFrame({'a':[1,2,3,4,5,6,7,100,9],
'b':[1,2,3,4,5,6,7,8,9]})
# These work, but are not what I want
df.rolling(3).corr()
df.corr(method='kendall')
>>> True
# This is what I want to do
df.rolling(3).corr(method='kendall')
>>> TypeError: count() got an unexpected keyword argument 'method'
解决方案
推荐阅读
- python - 每次运行python shell时如何执行一个函数
- wpf - WPF - 数据绑定(命令未执行)
- reactjs - 为什么在我的反应原生应用程序中按下每个键后键盘都会消失?
- python - 如何在 Python 中使用 tcp 套接字发送和接收网络摄像头流?
- spring - 如何在 Spring 中从 WebRequest 获取请求的 URI?
- json - SPARK - 无法读取多行 JSON (corrupt_record: string (nullable = true))
- symfony4 - Symfony 4 事件丢失和错误上的键入实体
- reactjs - 使用 redux 无法正确更新道具
- debugging - 使用 vue-cli-template 时调试 NativeScript-Vue
- css - nuget 更新后样式混乱。