Модель Python Arima X13 получает AttributeError: у объекта 'NoneType' нет атрибута 'setswith' - PullRequest
0 голосов
/ 03 октября 2018

Я пытаюсь запустить следующий код, и в конце кода я получаю эту ошибку:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import seaborn as sns
import statsmodels as sm
from statsmodels.tsa.x13 import x13_arima_select_order, _find_x12
import os

df_railroad=pd.read_csv('Input_Data1.csv')

XPATH = os.chdir('C:/Users/walkea24/Downloads/winx13_V2.5/WinX13/x13as')

df_railroad.rename(columns={'US Railroad Traffic Originated: Intermodal + 
Carloads (Units)':'Railroad'}, inplace=True)

df_railroad.set_index('Date', inplace=True)
temp_series = 
pd.DataFrame(df_railroad["Railroad"].values,index=df_railroad.index)
x13results = sm.tsa.x13.x13_arima_analysis(endog = 
temp_series,x12path=XPATH, freq='M',outlier=True,print_stdout=True)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
C:\PythonPlus\64bit\envs\Python36\lib\site-packages\statsmodels\tsa\x13.py 
in pandas_to_series_spec(x)
    291     try:
--> 292         period = _freq_to_period[x.index.freqstr]
    293     except (AttributeError, ValueError):

AttributeError: 'Index' object has no attribute 'freqstr'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-7-0721f586e7a5> in <module>()
      1 temp_series = 
pd.DataFrame(df_railroad["Railroad"].values,index=df_railroad.index)
----> 2 x13results = sm.tsa.x13.x13_arima_analysis(endog = 
temp_series,x12path=XPATH, freq='M',outlier=True,print_stdout=True)

C:\PythonPlus\64bit\envs\Python36\lib\site-packages\statsmodels\tsa\x13.py 
in x13_arima_analysis(endog, maxorder, maxdiff, diff, exog, log, outlier, 
trading, forecast_years, retspec, speconly, start, freq, print_stdout, 
x12path, prefer_x13)
    412                                                         
periods=len(endog),
    413                                                         freq=freq))
--> 414     spec_obj = pandas_to_series_spec(endog)
    415     spec = spec_obj.create_spec()
    416     spec += "transform{{function={0}}}\n".format(_log_to_x12[log])

C:\PythonPlus\64bit\envs\Python36\lib\site-packages\statsmodels\tsa\x13.py 
in pandas_to_series_spec(x)
    293     except (AttributeError, ValueError):
    294         from pandas.tseries.api import infer_freq
--> 295         period = _freq_to_period[infer_freq(x.index)]
    296     start_date = x.index[0]
    297     if period == 12:

C:\PythonPlus\64bit\envs\Python36\lib\site-packages\statsmodels\tsa\x13.py 
in __getitem__(self, key)
     29 class _freq_to_period:
     30     def __getitem__(self, key):
---> 31         if key.startswith('M'):
     32             return 12
     33         elif key.startswith('Q'):

AttributeError: 'NoneType' object has no attribute 'startswith'

Я не уверен, почему он говорит, что NoneType не имеет атрибута "setswith", потому что яиметь правильную настройку данных с моим левым столбцом в качестве индекса даты и справа в качестве значений.Statsmodels должен иметь возможность сделать вывод, что у меня есть переменная даты справа.Ниже приведено начало моих данных:

Дата создания железнодорожных перевозок в США. Интермодальные перевозки + вагоны (единицы). 1/31/1990 1593540 28/28/1990.31.05.1990 1710519 30.06.1990 2111856

...