在Python导入statsmodels.formula.api时,我得到一个ImportError:'无法导入名称'TimeSeries''。我已经读过其他用户的类比问题,但没有得到相关答案。我有statsmodels版本0.6.1和statsmodels.formula运行良好。您如何看待问题所在?先感谢您。感谢任何帮助:)
我正在使用Anaconda 4.3.1,Python 3.6.0,Statsmodels 0.6.1
在导入时获取的追溯是:
ImportError Traceback (most recent call last)
----> 1 import statsmodels.formula.api as sm
C:\Users\e.elis\AppData\Local\Continuum\Anaconda3\lib\site-
packages\statsmodels\formula\api.py in <module>()
----> 1 from statsmodels.regression.linear_model import GLS
2 gls = GLS.from_formula
3 from statsmodels.regression.linear_model import WLS
4 wls = WLS.from_formula
5 from statsmodels.regression.linear_model import OLS
C:\Users\e.elis\AppData\Local\Continuum\Anaconda3\lib\site-packages\statsmodels\regression\__init__.py in <module>()
----> 1 from .linear_model import yule_walker
2
3 from statsmodels import NoseWrapper as Tester
4 test = Tester().test
C:\Users\e.elis\AppData\Local\Continuum\Anaconda3\lib\site-packages\statsmodels\regression\linear_model.py in <module>()
50 cache_readonly,
51 cache_writable)
---> 52 import statsmodels.base.model as base
53 import statsmodels.base.wrapper as wrap
54 from statsmodels.emplike.elregress import _ELRegOpts
C:\Users\e.elis\AppData\Local\Continuum\Anaconda3\lib\site-packages\statsmodels\base\model.py in <module>()
3 import numpy as np
4 from scipy import stats
----> 5 from statsmodels.base.data import handle_data
6 from statsmodels.tools.tools import recipr, nan_dot
7 from statsmodels.stats.contrast import ContrastResults
C:\Users\e.elis\AppData\Local\Continuum\Anaconda3\lib\site-packages\statsmodels\base\data.py in <module>()
6 from statsmodels.compat.numpy import np_matrix_rank
7 import numpy as np
----> 8 from pandas import DataFrame, Series, TimeSeries, isnull
9 from statsmodels.tools.decorators import (resettable_cache, cache_readonly,
10 cache_writable)
ImportError: cannot import name 'TimeSeries'
答案 0 :(得分:1)
你的熊猫版本是什么,pandas 0.20+需要0.8或更新的统计模型。 参考:https://github.com/statsmodels/statsmodels/issues/3752