Skip to content

Instantly share code, notes, and snippets.

@balzer82
Last active June 20, 2022 14:38
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save balzer82/5cec6ad7adc1b550e7ee to your computer and use it in GitHub Desktop.
Save balzer82/5cec6ad7adc1b550e7ee to your computer and use it in GitHub Desktop.
TimeSeries Decomposition in Python with statsmodels and Pandas
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Cyberguille
Copy link

I follow the steps that you follow and I got
image

In my case I have a huge amount of data so is difficult review this data
What do you suggest me?
How can I create more big graph?
Is there a procedure for big time series??

@lotusirous
Copy link

@Cyberguille.

res = sm.tsa.seasonal_decompose(centrumGalerie.Belegung.interpolate(),
                                freq=decompfreq,
                                model='additive')

You can plot a bigger graph by plotting each graph separately. For example,

import matplotlib.pyplot as plt 

fig, (ax1,ax2,ax3) = plt.subplots(3,1, figsize=(15,8))
res.trend.plot(ax=ax1)
res.resid.plot(ax=ax2)
res.seasonal.plot(ax=ax3)

@IanQS
Copy link

IanQS commented Nov 22, 2018

Knowing the trend, seasonality and residuals, what do we do with them?

We want a trend that is fairly stable (like a straight line) before we do ARMA or ARIMA on the data, correct? We would do things like difference or log difference to address this issue?

What would we like from seasonal? Would we like it to be flat as well? How do we interpret the sinusoidal shape? And what cn we do to address seasonality?

@mekomlusa
Copy link

@IanQS That's what I'm trying to figure out as well. I got the nice plots from seasonal_decompose, now have no idea how to proceed...

@fclesio
Copy link

fclesio commented Oct 10, 2019

@Cyberguille

Just use that before the plot and you will be fine:

pylab.rcParams['figure.figsize'] = (14, 9)

@XiaoLaoDi
Copy link

when we get the decomposition components, how to predict the future steps?

@DavidD32-svg
Copy link

Thanks for your comments,

I also want to know how can i use this data in ARIMA or FOURIER.

@jcarless
Copy link

jcarless commented Oct 5, 2020

@Cyberguille

Just use that before the plot and you will be fine:

pylab.rcParams['figure.figsize'] = (14, 9)

Worked for me, thanks!

@pratikask
Copy link

Hi..am trying to use your method in my project and am using many issues. Can anyone help me decompose my time series??

@Ibitayoabiodun
Copy link

Just use that before the plot and you will be fine:

pylab.rcParams['figure.figsize'] = (14, 9)

Works perfectly!

@simonyelisey
Copy link

@pratikask if you still need a help I can help you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment