• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

使用dataframe.ewma找到指数加权移动平均线?

用户头像
it1352
帮助1

问题说明

以前,我使用以下内容来计算ewma

Previously I used the following to calculate the ewma

dataset['26ema'] = pd.ewma(dataset['price'], span=26)

但是,在最新版本的熊猫中,pd.ewma已被删除.如何使用新方法dataframe.ewma进行计算?

But, in the latest version of pandas pd.ewma has been removed. How to calculate using the new method dataframe.ewma?

dataset['26ema'] = dataset['price'].ewma(span=26)

这给出了错误"AttributeError:'系列'对象没有属性'ewma'

This is giving an error 'AttributeError: 'Series' object has no attribute 'ewma'

正确答案

#1

使用 GH11603 的信息新的.

See GH11603 for the relevant PR and mapping of the old API to new ones.

最小代码示例

s = pd.Series(range(5))
s.ewm(span=3).mean()

0    0.000000
1    0.666667
2    1.428571
3    2.266667
4    3.161290
dtype: float64

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfhjae
系列文章
更多 icon
同类精品
更多 icon
继续加载