Skip to main content
keep code inside of backticks and grammar correction for better understanding
Source Link

If you look at the documentation for STL(): https://www.statsmodels.org/stable/examples/notebooks/generated/stl_decomposition.htmlSTL()

You, you can see that there is a default of 7 for the seasonal period, if you do not have a frequency (which is what I think you have here).

The decomposition requires 1 input, the data series. If the data series does not have a frequency, then you must also specify period. The default value for seasonal is 7, and so should also be changed in most applications.

Hopefully, this will help!

I have also faced this issue when using stats model:

import statsmodels.api as sm
decomposition = sm.tsa.seasonal_decompose(df, model='additive')
fig = decomposition.plot()

I get the following error:

ValueError: You must specify importa statsmodels.apiperiod asor sm
x must be a pandas decompositionobject =with sm.tsa.seasonal_decompose(df,a model='additive')
DatetimeIndex with a freq fignot =set decomposition.plot()to None

I get the following error:

ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

However, when I set a period of 2, it works fine.

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, period = 2, 
    model='additive')
    fig = decomposition.plot()
import statsmodels.api as sm
decomposition = sm.tsa.seasonal_decompose(df, period = 2, 
model='additive')
fig = decomposition.plot()

The problem is, I have only yearly data, without monthly information, and no clear period to work with. Therefore, it is arbitrary (perhaps incorrect) to set a random period for my data set. If you do have a period (some seasonal time span) that you know of in your data, you can use this,this; otherwise, I am not sure how to help.

  See further the issue discussed here: decompose() for time series: ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to Nonehere.

If you look at the documentation for STL(): https://www.statsmodels.org/stable/examples/notebooks/generated/stl_decomposition.html

You can see that there is a default of 7 for seasonal period, if you do not have a frequency (which is what I think you have here).

The decomposition requires 1 input, the data series. If the data series does not have a frequency, then you must also specify period. The default value for seasonal is 7, and so should also be changed in most applications.

Hopefully, this will help!

I have also faced this issue when using stats model:

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, model='additive')
    fig = decomposition.plot()

I get the following error:

ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

However, when I set a period of 2, it works fine.

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, period = 2, 
    model='additive')
    fig = decomposition.plot()

The problem is, I have only yearly data, without monthly information, and no clear period to work with. Therefore, it is arbitrary (perhaps incorrect) to set a random period for my data set. If you do have a period (some seasonal time span) that you know of in your data, you can use this, otherwise, I am not sure how to help.

  See further the issue discussed here: decompose() for time series: ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

If you look at the documentation for STL(), you can see that there is a default of 7 for the seasonal period if you do not have a frequency (which is what I think you have here).

The decomposition requires 1 input, the data series. If the data series does not have a frequency, then you must also specify period. The default value for seasonal is 7, and so should also be changed in most applications.

Hopefully, this will help!

I have also faced this issue when using stats model:

import statsmodels.api as sm
decomposition = sm.tsa.seasonal_decompose(df, model='additive')
fig = decomposition.plot()

I get the following error:

ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

However, when I set a period of 2, it works fine.

import statsmodels.api as sm
decomposition = sm.tsa.seasonal_decompose(df, period = 2, 
model='additive')
fig = decomposition.plot()

The problem is, I have only yearly data, without monthly information, and no clear period to work with. Therefore, it is arbitrary (perhaps incorrect) to set a random period for my data set. If you have a period (some seasonal time span) in your data, you can use this; otherwise, I am not sure how to help. See further the issue discussed here.

added 538 characters in body
Source Link

If you look at the documentation for STL(): https://www.statsmodels.org/stable/examples/notebooks/generated/stl_decomposition.html

You can see that there is a default of 7 for seasonal period, if you do not have a frequency (which is what I think you have here).

The decomposition requires 1 input, the data series. If the data series does not have a frequency, then you must also specify period. The default value for seasonal is 7, and so should also be changed in most applications.

Hopefully, this will help!

I have also faced this issue when using stats model:

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, model='additive')
    fig = decomposition.plot()

I get the following error:

ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

However, when I set a period of 2, it works fine.

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, period = 2, 
    model='additive')
    fig = decomposition.plot()

The problem is, I have only yearly data, without monthly information, and no clear period to work with. Therefore, it is arbitrary (perhaps incorrect) to set a random period for my data set. If you do have a period (some seasonal time span) that you know of in your data, you can use this, otherwise, I am not sure how to help.

See further the issue discussed here: decompose() for time series: ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

I have also faced this issue when using stats model:

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, model='additive')
    fig = decomposition.plot()

I get the following error:

ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

However, when I set a period of 2, it works fine.

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, period = 2, 
    model='additive')
    fig = decomposition.plot()

The problem is, I have only yearly data, without monthly information, and no clear period to work with. Therefore, it is arbitrary (perhaps incorrect) to set a random period for my data set. If you do have a period (some seasonal time span) that you know of in your data, you can use this, otherwise, I am not sure how to help.

See further the issue discussed here: decompose() for time series: ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

If you look at the documentation for STL(): https://www.statsmodels.org/stable/examples/notebooks/generated/stl_decomposition.html

You can see that there is a default of 7 for seasonal period, if you do not have a frequency (which is what I think you have here).

The decomposition requires 1 input, the data series. If the data series does not have a frequency, then you must also specify period. The default value for seasonal is 7, and so should also be changed in most applications.

Hopefully, this will help!

I have also faced this issue when using stats model:

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, model='additive')
    fig = decomposition.plot()

I get the following error:

ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

However, when I set a period of 2, it works fine.

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, period = 2, 
    model='additive')
    fig = decomposition.plot()

The problem is, I have only yearly data, without monthly information, and no clear period to work with. Therefore, it is arbitrary (perhaps incorrect) to set a random period for my data set. If you do have a period (some seasonal time span) that you know of in your data, you can use this, otherwise, I am not sure how to help.

See further the issue discussed here: decompose() for time series: ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

Source Link

I have also faced this issue when using stats model:

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, model='additive')
    fig = decomposition.plot()

I get the following error:

ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

However, when I set a period of 2, it works fine.

    import statsmodels.api as sm
    decomposition = sm.tsa.seasonal_decompose(df, period = 2, 
    model='additive')
    fig = decomposition.plot()

The problem is, I have only yearly data, without monthly information, and no clear period to work with. Therefore, it is arbitrary (perhaps incorrect) to set a random period for my data set. If you do have a period (some seasonal time span) that you know of in your data, you can use this, otherwise, I am not sure how to help.

See further the issue discussed here: decompose() for time series: ValueError: You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None