statsmodels.formula.api importError: cannot import name 'TimeSeries'

statsmodels.formula.api importError: cannot import name 'TimeSeries'

import statsmodelsformula api as sm error
import statsmodels.api as sm error
statsmodels cannot import name unicode
importerror cannot import name exponentialsmoothing
importerror cannot import name 'logsumexp statsmodels
importerror cannot import name python3
importerror: cannot import name 'coroutine
statsmodels api pycharm

New to python here.

Using the following: Anaconda - v1.3.1 Spyder - v3.1.4 Python - v3.5

I am trying to import the following libraries:

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import statsmodels.formula.api as sm

It keeps giving me the following error:

import statsmodels.formula.api as sm
Traceback (most recent call last):

  File "<ipython-input-2-2515cefb61aa>", line 1, in <module>
    import statsmodels.formula.api as sm

  File "//anaconda/lib/python3.5/site-packages/statsmodels/formula/api.py", line 1, in <module>
    from statsmodels.regression.linear_model import GLS

  File "//anaconda/lib/python3.5/site-packages/statsmodels/regression/__init__.py", line 1, in <module>
    from .linear_model import yule_walker

  File "//anaconda/lib/python3.5/site-packages/statsmodels/regression/linear_model.py", line 52, in <module>
    import statsmodels.base.model as base

  File "//anaconda/lib/python3.5/site-packages/statsmodels/base/model.py", line 5, in <module>
    from statsmodels.base.data import handle_data

  File "//anaconda/lib/python3.5/site-packages/statsmodels/base/data.py", line 8, in <module>
    from pandas import DataFrame, Series, TimeSeries, isnull

ImportError: cannot import name 'TimeSeries'

I read some posts about updating pandas. I tried that but it doesn't work. Any ideas as to the error and a solution? (It works fine when I import only statsmodel.formula or just statsmodel)


For python3:

You need to upgrade statsmodels. If that is a problem go for a specific version such as:

py -m pip install statsmodels==0.6.0

Then you can use

py -m pip install statsmodels --upgrade

For python2.x

pip install statsmodels --upgrade

python 3.5 in statsmodels ImportError: cannot import name , Please see the github report for more detail. It turns out that statsmodels is dependent upon several packages being installed before it so that it  While in Python importing statsmodels.formula.api i get an ImportError: 'cannot import name 'TimeSeries''. I ve read about the analogic problems other users have but didnt get the relevant answer from there. I have the statsmodels version 0.6.1 and statsmodels.formula works well. How do you think where the problem is? Thank you in advance.


Upgrading statsmodels worked for me,

pip install statsmodels --upgrade

unable to import statsmodels.api · Issue #5572 · statsmodels , ImportError: cannot import name 'DynamicVAR' from 'statsmodels.tsa.api' when I entered 'from statsmodels.formula.api import ols'. Code Sample, a copy-pastable example if possible from statsmodels.formula.api import ols or even import statsmodels.api as sm Expected Output pip installing the package shouldn't install incompatible types.


The above solutions didn't quite worked for me when working on azure databricks. But one thing worked for me, which I am not sure why. So when I restarted my notebook and imported as listed below it worked. Please comment if this worked for you and also in case you may have any idea why this worked.

    import statsmodels
    import statsmodels.api as sm
    import statsmodels.formula.api as smf

ImportError: cannot import name 'factorial' with pip installed , All the more reason to finish #5620. Code Sample, a copy-pastable example if possible. from statsmodels.formula.api import  ImportError: cannot import name '_representation' in python3.5 (all modules upgraded) 0 Importing statsmodels in RHEL fails with undefined symbol: PyUnicodeUCS4_DecodeUTF8


Use this

import statsmodels.api as sm

Python statsmodel.api error, module 'statsmodels.formula.api' has no attribute 'ols' importerror cannot import name exponentialsmoothing update statsmodels api importerror cannot import  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more ImportError: No module named statsmodels


How to import statsmodels module to use OLS class?, importerror: cannot import name 'unicode' import statsmodels.api as sm error module 'statsmodels.formula.api' has no attribute 'ols' importerror cannot import  ----> 2 from statsmodels.compat.pandas import is_numeric_dtype 3 4 import datetime 5 ~\Anaconda3\lib\site-packages\statsmodels\compat\pandas.py in 54 import pandas.tseries.frequencies as frequencies 55 except ImportError:---> 56 from pandas.core import datetools 57 frequencies = datetools. ImportError: cannot import name 'datetools'


ImportError: cannot import name 'factorial' – Icetutor, import statsmodels.formula.api as sm import rv_continuous 9 import scipy.​special as special ImportError: cannot import name 'factorial'. !pip install scipy==1.2 --user import statsmodels.formula.api as sm from statsmodels.formula.api import ols from statsmodels.sandbox.regression.predstd import wls_prediction_std` I still got the following after scipy 1.2 was successfully installed: ImportError: cannot import name 'factorial' from 'scipy.misc'


Importerror cannot import name basemodel, See https://stackoverflow.com/a/56284155/9524424. You need to have a matching scipy version (1.2 instead of 1.3). python 3.5 in statsmodels ImportError: cannot import name '_representation' 0 Importing statsmodels in RHEL fails with undefined symbol: PyUnicodeUCS4_DecodeUTF8