I'm trying to implement Time series forecasting in Python using Pandas n statsmodels. I want to read a local excel file data and then decompose it into Trends & Seasonal components but I'm unable to get any relevant links which shows how to load data from local drive.
I tried using the following code:
excel = pandas.ExcelFile( 'PET_PRI_SPT_S1_D.xls' )
df = excel.parse( excel.sheet_names[1] )
dta = sm.datasets.co2.load_pandas().data
dta.co2.interpolate(inplace=True)
res = sm.tsa.seasonal_decompose(dta.co2)
resplot = res.plot()
res.resid
But its if I try printing dta variable, it shows some other data and not PET_PRI_SPT_S1_D.xls. Even resplot=res.plot() doesn't seem to work and no plot shows up.
Can you please guide me on how to load data from local drive into pandas dataframe.
Edit 1:
I get following when I tried df.info(). Here df is object of my excel file.
DatetimeIndex: 7509 entries, 1986-01-24 00:00:00 to 2015-06-08 00:00:00 Data columns (total 2 columns): WTI 7408 non-null object Brent 7115 non-null object dtypes: object(2) memory usage: 117.3+ KB
When I try dta.info() where dta is object of sm.datasets.co2 type, I get following.
DatetimeIndex: 2284 entries, 1958-03-29 00:00:00 to 2001-12-29 00:00:00 Freq: W-SAT Data columns (total 1 columns): co2 2284 non-null float64 dtypes: float64(1) memory usage: 35.7 KB