11

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

1 Answers1

13

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.

spin_cycle
  • 131
  • 1
  • 3