4

I am totally beginner in Python and after using seasonal_decompose for time series decomposition result=seasonal_decompose(series, model='additive', freq=365) I got plotted results with commands result.plot() and pyplot.show(), but I cannot understand how to print this results values on screen or how to see decomposed time series values? I have plot, but I need to have values in console or some data file.

Complete code:

from pandas import read_csv
series=read_csv('B.csv', header=0, parse_dates=[0], index_col=0, squeeze=True)
from random import randrange
from matplotlib import pyplot
from statsmodels.tsa.seasonal import seasonal_decompose
result=seasonal_decompose(series, model='additive', freq=365)
result.plot()
pyplot.show()
nick_name
  • 205
  • 2
  • 8

1 Answers1

6

seasonal_decompose returns an 'object with seasonal, trend, and resid attributes.' We can access the data by calling the object:

res = seasonal_decompose(series, model='additive', freq=365)
residual = res.resid
seasonal = res.seasonal 
trend = res.trend
print trend

etc...

Hobbes
  • 1,469
  • 9
  • 15