简体   繁体   中英

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.

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.

Since I need to find a 12 day moving average hence min_period=12. I interpret span as total number of values in a data set or the total time covered.

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.

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”.

In your case, set span=12. You do not need to specify that you have 20 datapoints, pandas takes care of that. min_period may not be required here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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