简体   繁体   English

使用Pandas的指数加权移动平均线

[英]Exponential Weighted Moving Average using Pandas

I need to confirm few thing related to pandas exponential weighted moving average function. 我需要确认一些与熊猫指数加权移动平均函数有关的事情。

If I have a data set df for which I need to find a 12 day exponential moving average, would the method below be correct. 如果我有一个数据集df,我需要找到一个12天的指数移动平均值,下面的方法是否正确。

exp_12=df.ewm(span=20,min_period=12,adjust=False).mean()

Given the data set contains 20 readings the span (Total number of values) should equal to 20. 给定数据集包含20个读数,跨度(值的总数)应等于20。

Since I need to find a 12 day moving average hence min_period=12. 因为我需要找到12天的移动平均线,因此min_period = 12。 I interpret span as total number of values in a data set or the total time covered. 我将span解释为数据集中值的总数或所涵盖的总时间。

Can someone confirm if my above interpretation is correct? 有人可以确认我的上述解释是否正确? I can't get the significance of adjust. 我无法得到调整的意义。

I've attached the link to pandas.df.ewm documentation below. 我已将链接附加到下面的pandas.df.ewm文档中。

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ewm.html http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ewm.html

Quoting from Pandas docs : Span corresponds to what is commonly called an “N-day EW moving average”. 引自Pandas docs :Span对应于通常所说的“N日EW移动平均线”。

In your case, set span=12. 在您的情况下,设置span = 12。 You do not need to specify that you have 20 datapoints, pandas takes care of that. 您不需要指定您有20个数据点,pandas负责这一点。 min_period may not be required here. 这里可能不需要min_period。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM