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

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 have read several posts about pandas update. I tried this but it doesn't work. Any ideas regarding the error and solution? (It works great when I only import statsmodel.formula or just statsmodel)

+5


source to share


3 answers


For python3 :

You need to update statsmodels. If this is a problem, refer to a specific version, for example:

py -m pip install statsmodels==0.6.0



Then you can use

py -m pip install statsmodels --upgrade

+1


source


Upgrading the statistics models worked for me,



pip install statsmodels --upgrade

+15


source


The solutions above didn't quite work for me when dealing with azure data blocks. But one thing worked for me that I'm not sure why. So when I restarted my laptop and imported as below, it worked. Please comment if this worked for you and also in case you can understand why it worked.

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

      

0


source







All Articles