George Ng
George Ng

Reputation: 111

Importing stldecompose result in error - cannot import name '_maybe_get_pandas_wrapper_freq' from 'statsmodels.tsa.filters._utils'

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)

Upvotes: 2

Views: 5665

Answers (1)

yanger rai
yanger rai

Reputation: 112

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

Upvotes: 4

Related Questions