#StackBounty: #time-series #seasonality #trend #statsmodels #decomposition statsmodels seasonal_decompose(): What is the right "pe…

Bounty: 50

Assume having a list column so that your time series is nested, see https://stackoverflow.com/questions/63246938/convert-pandas-df-with-data-in-a-list-column-into-a-time-series-in-long-format for details. The question here is not about how to unnest a list column though. Assume that you already have a long format structure with all available list elements unnested into a normal column, here for example taking 2 lists with 4 list elements, making 8 rows in the end.

Part1: Assume that every list of the original list column has the same number of list elements (here, the first list with 4 items around 08:53, and the second with 4 items around 08:55).

                     value
datetimeindex
2016-05-04 08:53:20  1
2016-05-04 08:53:21  2
2016-05-04 08:53:22  1
2016-05-04 08:53:23  9
2016-05-04 08:55:00  2
2016-05-04 08:55:01  2
2016-05-04 08:55:02  3
2016-05-04 08:55:03  0

Now approaching the actual question. From https://www.statsmodels.org/stable/generated/statsmodels.tsa.seasonal.seasonal_decompose.html we read:

Definition of period

"period, int, optional"

Period of the series. Must be used if x is not a pandas object or if
the index of x does not have a frequency. Overrides default
periodicity of x if x is a pandas object with a timeseries index.

What is meant here with "Period of the series"? Is it:

  1. the number of lists, here 2.
  2. the standard size of a list. This would be 4 in the example.
  3. something else than 1./2.

Please also explain what would be different if you had a "Part2 setting", if there is any difference:

Part2: Assume that every list of the original list column has a varying number of list elements (here, the first list with 4 items around 08:53, and the second with just 3 items around 08:55).

                     value
datetimeindex
2016-05-04 08:53:20  1
2016-05-04 08:53:21  2
2016-05-04 08:53:22  1
2016-05-04 08:53:23  9
2016-05-04 08:55:00  2
2016-05-04 08:55:01  2
2016-05-04 08:55:02  3

The examples shall make the question clear, no programming (especially not with the examples) needed for an accepted answer.

Context:

This question arose from https://stackoverflow.com/questions/60017052/decompose-for-time-series-valueerror-you-must-specify-a-period-or-x-must-be/63252466. I had the same issue, thus I added an answer there just as a beginner. Now I try to improve that explanation with the help of Cross Validated SE.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.