如何使用dataframe.ewma找到指数加权移动平均线? [英] how to find exponential weighted moving average using dataframe.ewma?

查看:481
本文介绍了如何使用dataframe.ewma找到指数加权移动平均线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前,我使用以下内容来计算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'

推荐答案

使用有关PR和将旧API映射到 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

这篇关于如何使用dataframe.ewma找到指数加权移动平均线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆