title: Find SARIMAX AIC and pdq values, statsmodels
body: <p>I'm trying to find the values of p,d,q and the seasonal values of P,D,Q using statsmodels as "sm" in python.</p>
  
  <p>The data set i'm using is a csv file that contains time series data over three years recording the energy consumption. The file was split into a smaller data frame in order to work with it. Here is what df_test.head() looks like.</p>
  
  <pre><code>                      time  total_consumption
  122400 2015-05-01 00:01:00            106.391
  122401 2015-05-01 00:11:00            120.371
  122402 2015-05-01 00:21:00            109.292
  122403 2015-05-01 00:31:00             99.838
  122404 2015-05-01 00:41:00             97.387
  </code></pre>
  
  <p>Here is my code so far.</p>
  
  <pre><code>#Importing the timeserie data set from local file
  df = pd.read_csv(r"C:\Users\path\Name of the file.csv")
  
  #Rename the columns, put time as index and assign datetime to the column time
  df.columns = ["time","total_consumption"]
  df['time'] = pd.to_datetime(df.time)
  df.set_index('time')
  
  #Select test df (there is data from the 2015-05-01 2015-06-01)
  df_test = df.loc[(df['time'] &gt;= '2015-05-01') &amp; (df['time'] &lt;= '2015-05-14')]
  
  #Find minimal AIC value for the ARIMA model integers
  p = range(0,2)
  d = range(0,2)
  q = range(0,2)
  
  pdq = list(itertools.product(p,d,q))
  
  seasonal_pdq = [(x[0], x[1], x[2], 12) for x in list(itertools.product(p,d,q))]
  
  warnings.filterwarnings("ignore")
  
  for param in pdq:
      for param_seasonal in seasonal_pdq:
          try:
              mod = sm.tsa.statespace.SARIMAX(df_test,
                                              order=param,
                                              seasonal_order=param_seasonal,
                                              enforce_stationarity=False,
                                              enforce_invertibility=False)
  
              results = mod.fit()
              print('ARIMA{}x{}12 - AIC:{}'.format(param, param_seasonal, results.aic))
  
          except:
              continue
  </code></pre>
  
  <p>When I try to run the code as it is, the program doesn't even acknowledge the "for" loop. But when I take out the</p>
  
  <pre><code>try:
  except:
      continue
  </code></pre>
  
  <p>the program gives me this error message</p>
  
  <pre><code>ValueError: Pandas data cast to numpy dtype of object. Check input data with np.asarray(data).
  </code></pre>
  
  <p>How could I remedy that and is there a way to automate the process directly output the parameters with the lowest AIC value (without having to look for it throught all the possibilities).</p>
  
  <p>Thanks !</p>