Removing trend and seasonality
As mentioned earlier, a time series is stationary if, and only if, its mean does not depend on time, its variance is constant and also does not depend on time, and the autocorrelation does not vary either. This means that any time process with a trend and seasonality is not stationary.
The ARMA and ARIMA models that we will introduce in the next recipe require the data to be stationary (or close to). Thus, in this recipe, you will learn how to remove trend and seasonality from our river flow data.
Getting ready
To execute this recipe, you will need pandas
, NumPy
, Statsmodels
, and Matplotlib
. No other prerequisites are required.
How to do it…
Statsmodels
provides convenience methods that will help us detrend and remove ...
Get Practical Data Analysis Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.