我正尝试在我的Python 3.6(anaconda \ spider)中使用statsmodels.tsa.x13。我已经安装了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'
出什么问题了?我将不胜感激。
答案 0 :(得分:0)
您需要以字符串形式传递。更改
X13PATH= os.chdir("C:\\x13\WinX13\\x13as")
到
X13PATH= "C:\\x13\WinX13\\x13as"
从statsmodels docs:“ x12path(str或None)–指向x12或x13二进制文件的路径。如果为None,则程序将尝试在PATH上或通过查看X13PATH或X12PATH来查找x13as或x12a,具体取决于的值放在preferred_x13上。”