January 2020
Beginner to intermediate
432 pages
11h 24m
English
Execute the following steps to transform the series from non-stationary to stationary.
import cpiimport pandas as pdfrom datetime import datefrom statsmodels.graphics.tsaplots import plot_acf, plot_pacffrom statsmodels.tsa.stattools import adfuller, kpssfrom chapter_3_utils import test_autocorrelation# update the CPI data (if needed)# cpi.update()
DEFL_DATE = date(2011, 12, 31)df['dt_index'] = df.index.map(lambda x: x.to_pydatetime().date())df['price_deflated'] = df.apply(lambda x: cpi.inflate(x.price, x.dt_index, DEFL_DATE), axis=1)df[['price', 'price_deflated']].plot(title='Gold Price (deflated)'); ...
Read now
Unlock full access