Reputation: 11
Please focus on the block near the bottom of my notebook. I can't do a forecast with an error message "ValueError: Dataframe has less than 2 non-NaN rows."
What Can I do to resolve it ???
tic = time.time()
for s in proph_results['shop_id'].unique():
for i in proph_results['item_id'].unique():
proph_train = train.loc[(train['shop_id'] == s) & (train['item_id'] == i)].reset_index()
proph_train.rename(columns={'date': 'ds', 'item_cnt_day': 'y'}, inplace=True)
m = Prophet()
m.fit(proph_train[['ds', 'y']])
future = m.make_future_dataframe(periods=len(test_old.index.unique()), include_history=False)
fcst = m.predict(future)
proph_results.loc[(proph_results['shop_id'] == s) & (proph_results['item_id'] == i), 'sales'] = fcst['yhat'].values
toc = time.time()
if i % 10 == 0:
print("Completed store {} item {}. Cumulative time: {:.1f}s".format(s, i, toc-tic))
Upvotes: 0
Views: 8824
Reputation: 802
Prophet
cannot be used when number of rows (which are not null) in the data you're passing is less than 2. So, you cannot do the prediction in that case.
So you get an error when you're fitting the model.
There's no other solution other than adding more (not null) data to the existing.
Upvotes: 8