Skip to content

Sarimax model #5

@ABHI-105520

Description

@ABHI-105520

### I'm getting error in predict_df when i call sarimax_model(ts_data)...

KeyError Traceback (most recent call last)
File ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py:3629, in Index.get_loc(self, key, method, tolerance)
3628 try:
-> 3629 return self._engine.get_loc(casted_key)
3630 except KeyError as err:

File ~\anaconda3\lib\site-packages\pandas_libs\index.pyx:136, in pandas._libs.index.IndexEngine.get_loc()

File ~\anaconda3\lib\site-packages\pandas_libs\index.pyx:163, in pandas._libs.index.IndexEngine.get_loc()

File pandas_libs\hashtable_class_helper.pxi:5198, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas_libs\hashtable_class_helper.pxi:5206, in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 0

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last)
Cell In [23], line 5
3 ts_data.index = pd.to_datetime(ts_data.index)
4 ts_data.head()
----> 5 sarimax_model(ts_data)

Cell In [11], line 15, in sarimax_model(data)
13 # Generate predictions dataframe
14 original_df = load_data('monthly_data.csv')
---> 15 unscaled_df = predict_df(data, original_df)
17 # print scores and plot results
18 get_scores(unscaled_df, original_df, 'ARIMA')

Cell In [22], line 18, in predict_df(unscaled_predictions, original_df)
16 for index in range(0, len(unscaled_predictions)):
17 result_dict = {}
---> 18 result_dict['pred_value'] = int(unscaled_predictions[index][0] + act_sales[index])
19 result_dict['date'] = sales_dates[index+1]
20 result_list.append(result_dict)

File ~\anaconda3\lib\site-packages\pandas\core\frame.py:3505, in DataFrame.getitem(self, key)
3503 if self.columns.nlevels > 1:
3504 return self._getitem_multilevel(key)
-> 3505 indexer = self.columns.get_loc(key)
3506 if is_integer(indexer):
3507 indexer = [indexer]

File ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py:3631, in Index.get_loc(self, key, method, tolerance)
3629 return self._engine.get_loc(casted_key)
3630 except KeyError as err:
-> 3631 raise KeyError(key) from err
3632 except TypeError:
3633 # If we have a listlike key, _check_indexing_error will raise
3634 # InvalidIndexError. Otherwise we fall through and re-raise
3635 # the TypeError.
3636 self._check_indexing_error(key)

KeyError: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions