April 2016
Beginner to intermediate
384 pages
8h 36m
English
Smoothing data removes some of the noise from the data and makes the chart appear smooth (hence the name).
Should you do it? For presentation purposes, sure! For modeling purposes, not necessarily—check this argument by William Briggs at http://wmbriggs.com/post/195/.
To execute this recipe, you will need pandas, NumPy, and Matplotlib. No other prerequisites are required.
In this recipe, we will see how to calculate the moving averages and transform the data using a logarithmic function (the ts_smoothing.py file):
ma_transform12 = pd.rolling_mean(riverFlows, window=12) ma_transformExp = pd.ewma(riverFlows, span=3) log_transfrom = riverFlows.apply(np.log)
The .rolling_mean(...) ...
Read now
Unlock full access