2

My code

!pip install stldecompose

from stldecompose import decompose

Error Msg


ImportError Traceback (most recent call last) in 2 # Install the library via PIP 3 get_ipython().system('pip install stldecompose') ----> 4 from stldecompose import decompose, forecast

~/opt/anaconda3/lib/python3.7/site-packages/stldecompose/init.py in ----> 1 from .stl import decompose, forecast

~/opt/anaconda3/lib/python3.7/site-packages/stldecompose/stl.py in 3 from pandas.core.nanops import nanmean as pd_nanmean 4 from statsmodels.tsa.seasonal import DecomposeResult ----> 5 from statsmodels.tsa.filters._utils import _maybe_get_pandas_wrapper_freq 6 import statsmodels.api as sm 7

ImportError: cannot import name '_maybe_get_pandas_wrapper_freq' from 'statsmodels.tsa.filters._utils' (/Users/georgeng/opt/anaconda3/lib/python3.7/site-packages/statsmodels/tsa/filters/_utils.py)

1 Answer 1

4

You have two pathway to go about this:

  1. If you are running statsmodels==0.11.0, statsmodels.tsa.filters._utils function was removed from the library.

Alternatively you may use statsmodels.tsa.seasonal.STL, which gives similar functionality. See its documentation: https://www.statsmodels.org/stable/generated/statsmodels.tsa.seasonal.STL.html#statsmodels.tsa.seasonal.STL

  1. Downgrade to pip install statsmodels==0.10.2
Sign up to request clarification or add additional context in comments.

3 Comments

Downgrading options doesn't solve the issue, although indeed that's what was suggested in the relevant Github issue: github.com/jrmontag/STLDecompose/issues/17
A note: This answer was written in 2020, tried, tested and worked. But it might not now, please refer the official documentation for an accurate troubleshooting steps
It's ok to use from statsmodels.tsa.seasonal import STL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.