X-13-ARIMA statsmodels.tsa.x13

X-13-ARIMA with statsmodels.tsa.x13

我正在尝试将 statsmodels.tsa.x13 与我的 Python 3.6 (anaconda\spider) 一起使用。我已经安装了 x13as 并编写了这段代码:

X13PATH= os.chdir("C:\x13\WinX13\x13as")
x13results = x13_arima_analysis(endog = mb["G"], x12path=X13PATH, outlier=True,print_stdout=True)

其中 mb["G"] 是 pandas.core.series.Series。所以,结果如下:

C:\Anaconda\lib\site-packages\statsmodels\tsa\x13.py:460: IOWarning: Failed to delete resource C:\Users\SERGEY~1\AppData\Local\Temp\tmp2iwvb0uo.spc 
  IOWarning)
C:\Anaconda\lib\site-packages\statsmodels\tsa\x13.py:463: IOWarning: Failed to delete resource C:\Users\SERGEY~1\AppData\Local\Temp\tmp_h3vwxc9 
  IOWarning)
Traceback (most recent call last):

 File "<ipython-input-3-8e98768a4534>", line 2, in <module>     
  x13results = x13_arima_analysis(endog = mb["G"], x12path=X13PATH, outlier=True,print_stdout=True)

 File "C:\Anaconda\lib\site-packages\statsmodels\tsa\x13.py", line 434, in x13_arima_analysis     
  ftempin.write(spec)

 File "C:\Anaconda\lib\tempfile.py", line 483, in func_wrapper    
   return func(*args, **kwargs)

TypeError: a bytes-like object is required, not 'str'

有什么问题吗?我将不胜感激。

您需要以字符串形式传递。变化

X13PATH= os.chdir("C:\x13\WinX13\x13as")

X13PATH= "C:\x13\WinX13\x13as"

来自statsmodels docs:"x12path (str or None) – The path to x12 or x13 binary. If None, the program will attempt to find x13as or x12a on the PATH or by looking at X13PATH or X12PATH depending on the value of prefer_x13."