Differencing time series data
When time series data is not stationary, we can use a technique called differencing to make it stationary. Differencing involves subtracting the current values from the preceding values to remove the trends or seasonality present in the time series. First-order differencing happens when we subtract each value from the preceding value by one time period. Differencing can be done several times, and this is known as higher-order differencing. This helps us remove higher levels of trend or seasonality. However, the downside of differencing too many times is that we may lose vital information from the original time series data.
We will explore the differencing technique in Python. We will use the diff
method in pandas
.
Getting ready
We will work with the San Francisco Air Traffic Passenger Statistics data from Kaggle in this recipe. You can retrieve all the files from the GitHub repository.
How to do it…
We will learn how to implement...