0

My notebook in kaggle

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))
Jeffery Wong
  • 11
  • 1
  • 5

1 Answers1

7

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.

Paradox
  • 738
  • 12
  • 30
Ganesh Jadhav
  • 712
  • 6
  • 22
  • 3
    Maybe you should take a look at [How to answer](https://stackoverflow.com/help/how-to-answer) and be careful with the formatting and excessive exclamation points, for example. Also, brief answers can be good but they need some strong points. – Paradox Mar 25 '19 at 20:27
  • similar issues i am facing but i did not do the looping model.fit. can you please some one help – Developer KE Mar 30 '23 at 11:05