2016-04-29 117 views
2

步驟1:我的樣本數據的Python Statsmodels x13_arima_analysis:AttributeError的: '快譯通' 對象有沒有屬性 'iteritems'

import pandas as pd 
from pandas import Timestamp 

s = pd.Series(
    {Timestamp('2013-03-01 00:00:00'): 838.2, 
Timestamp('2013-04-01 00:00:00'): 865.17, 
Timestamp('2013-05-01 00:00:00'): 763.0, 
Timestamp('2013-06-01 00:00:00'): 802.99, 
Timestamp('2013-07-01 00:00:00'): 875.56, 
Timestamp('2013-08-01 00:00:00'): 754.4, 
Timestamp('2013-09-01 00:00:00'): 617.48, 
Timestamp('2013-10-01 00:00:00'): 994.75, 
Timestamp('2013-11-01 00:00:00'): 860.86, 
Timestamp('2013-12-01 00:00:00'): 786.66, 
Timestamp('2014-01-01 00:00:00'): 908.48, 
Timestamp('2014-02-01 00:00:00'): 980.88, 
Timestamp('2014-03-01 00:00:00'): 1453.73, 
Timestamp('2014-04-01 00:00:00'): 1473.33, 
Timestamp('2014-05-01 00:00:00'): 1480.44, 
Timestamp('2014-06-01 00:00:00'): 1433.91, 
Timestamp('2014-07-01 00:00:00'): 1386.58, 
Timestamp('2014-08-01 00:00:00'): 1437.35, 
Timestamp('2014-09-01 00:00:00'): 1207.07, 
Timestamp('2014-10-01 00:00:00'): 973.3, 
Timestamp('2014-11-01 00:00:00'): 962.18, 
Timestamp('2014-12-01 00:00:00'): 717.69, 
Timestamp('2015-01-01 00:00:00'): 873.06, 
Timestamp('2015-02-01 00:00:00'): 881.65, 
Timestamp('2015-03-01 00:00:00'): 1252.92, 
Timestamp('2015-04-01 00:00:00'): 866.94, 
Timestamp('2015-05-01 00:00:00'): 1498.05, 
Timestamp('2015-06-01 00:00:00'): 1282.31, 
Timestamp('2015-07-01 00:00:00'): 1411.33, 
Timestamp('2015-08-01 00:00:00'): 1379.05, 
Timestamp('2015-09-01 00:00:00'): 1334.52, 
Timestamp('2015-10-01 00:00:00'): 1231.86, 
Timestamp('2015-11-01 00:00:00'): 1088.14, 
Timestamp('2015-12-01 00:00:00'): 967.35, 
Timestamp('2016-01-01 00:00:00'): 1266.37, 
Timestamp('2016-02-01 00:00:00'): 1278.79, 
Timestamp('2016-03-01 00:00:00'): 1497.8, 
Timestamp('2016-04-01 00:00:00'): 1352.27}, 
    name='Cost') 

步驟2:我在Windows操作系統

下載 X-13ARIMA-SEATS Seasonal Adjustment Program到我的下載文件夾

步驟3:在Python的IDLE IDE,我改變了我的電流路徑,這個節目的居住地:

import os 
os.chdir(r'C:\Users\owner\Downloads\x13asall_V1.1_B26\x13as') 

步驟4:我進口statsmodels並嘗試運行x13_arima_analysis如下:

import statsmodels.api as sm 
sm.tsa.x13_arima_analysis(s) 

錯誤接收:

Traceback (most recent call last): 
    File "<pyshell#104>", line 1, in <module> 
    sm.tsa.x13_arima_analysis(s) 
    File "C:\Python34\lib\site-packages\statsmodels-0.6.1-py3.4-win-amd64.egg\statsmodels\tsa\x13.py", line 417, in x13_arima_analysis 
    spec_obj = pandas_to_series_spec(endog) 
    File "C:\Python34\lib\site-packages\statsmodels-0.6.1-py3.4-win-amd64.egg\statsmodels\tsa\x13.py", line 310, in pandas_to_series_spec 
    stperiod)) 
    File "C:\Python34\lib\site-packages\statsmodels-0.6.1-py3.4-win-amd64.egg\statsmodels\tsa\x13.py", line 271, in __init__ 
    title=title, name=series_name, 
    File "C:\Python34\lib\site-packages\statsmodels-0.6.1-py3.4-win-amd64.egg\statsmodels\tsa\x13.py", line 218, in set_options 
    for key, value in kwargs.iteritems(): 
AttributeError: 'dict' object has no attribute 'iteritems' 

請注意,我已經安裝statsmodels的unofficial binaries(因爲這是不可能的安裝在我的Windows機器上),所以我不認爲我可以改變實際的源,但我確實看到問題是here on this line

我在做這個錯誤還是這是statsmodels內的錯誤?

我有什麼版本的statsmodels? 0.6.1

>>> sm.__spec__ 
ModuleSpec(name='statsmodels.api', loader=<_frozen_importlib.SourceFileLoader object at 0x0000000007193470>, origin='C:\\Python34\\lib\\site-packages\\statsmodels-0.6.1-py3.4-win-amd64.egg\\statsmodels\\api.py') 
+0

東西seemf斷,通常類型的字典具有'iteritems'操作者,通過'打印dict.iteritem'檢查:''<方法 'iteritems' 的'dict'objects>' –

回答

0

不知道我是否應該關閉這個問題,或保持它給其他人蔘考,隨着越來越x13_arima_analysis工作努力。總而言之,我通過修改了幾行來完成工作......但最終,我建議首先訪問Github,並使用latest Github code替換位於機器上的C:\Python34\Lib\site-packages\statsmodels-0.6.1-py3.4-win-amd64.egg\statsmodels‌​\tsa文件中的x13.py文件,以查看它是否修復了該文件爲你。它爲我解決它。

工作實施例中的操作:

import pandas as pd 
from pandas import Timestamp 
import os 
import matplotlib.pyplot as plt 
import statsmodels.api as sm 

PATH =r'C:\Users\owner\Downloads\x13asall_V1.1_B26\x13as' 

os.chdir(PATH) 

s = pd.Series(
    {Timestamp('2013-03-01 00:00:00'): 838.2, 
Timestamp('2013-04-01 00:00:00'): 865.17, 
Timestamp('2013-05-01 00:00:00'): 763.0, 
Timestamp('2013-06-01 00:00:00'): 802.99, 
Timestamp('2013-07-01 00:00:00'): 875.56, 
Timestamp('2013-08-01 00:00:00'): 754.4, 
Timestamp('2013-09-01 00:00:00'): 617.48, 
Timestamp('2013-10-01 00:00:00'): 994.75, 
Timestamp('2013-11-01 00:00:00'): 860.86, 
Timestamp('2013-12-01 00:00:00'): 786.66, 
Timestamp('2014-01-01 00:00:00'): 908.48, 
Timestamp('2014-02-01 00:00:00'): 980.88, 
Timestamp('2014-03-01 00:00:00'): 1453.73, 
Timestamp('2014-04-01 00:00:00'): 1473.33, 
Timestamp('2014-05-01 00:00:00'): 1480.44, 
Timestamp('2014-06-01 00:00:00'): 1433.91, 
Timestamp('2014-07-01 00:00:00'): 1386.58, 
Timestamp('2014-08-01 00:00:00'): 1437.35, 
Timestamp('2014-09-01 00:00:00'): 1207.07, 
Timestamp('2014-10-01 00:00:00'): 973.3, 
Timestamp('2014-11-01 00:00:00'): 962.18, 
Timestamp('2014-12-01 00:00:00'): 717.69, 
Timestamp('2015-01-01 00:00:00'): 873.06, 
Timestamp('2015-02-01 00:00:00'): 881.65, 
Timestamp('2015-03-01 00:00:00'): 1252.92, 
Timestamp('2015-04-01 00:00:00'): 866.94, 
Timestamp('2015-05-01 00:00:00'): 1498.05, 
Timestamp('2015-06-01 00:00:00'): 1282.31, 
Timestamp('2015-07-01 00:00:00'): 1411.33, 
Timestamp('2015-08-01 00:00:00'): 1379.05, 
Timestamp('2015-09-01 00:00:00'): 1334.52, 
Timestamp('2015-10-01 00:00:00'): 1231.86, 
Timestamp('2015-11-01 00:00:00'): 1088.14, 
Timestamp('2015-12-01 00:00:00'): 967.35, 
Timestamp('2016-01-01 00:00:00'): 1266.37, 
Timestamp('2016-02-01 00:00:00'): 1278.79, 
Timestamp('2016-03-01 00:00:00'): 1497.8, 
Timestamp('2016-04-01 00:00:00'): 1352.27}, 
    name='Cost') 


res = sm.tsa.x13_arima_analysis(s) 
res.plot() 
plt.show() 

enter image description here

+0

嗨,我使用的是一個用於python的Anaconda前端。你能告訴我如何爲我的情況實現x13。在窗戶上 – Nck

相關問題