New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
version 0.4 holidays error: KeyError: '[] not found in axis' #821
Comments
I haven't run into this myself yet, could you post an example dataframe and the code that produces this error? |
I ran into the same error (Pandas 0.23.0, fbprophet 0.4.post2, Python 2.7). It seems to occur in predict() when the
The root cause of the error is that when these conditions are met, an empty list is passed into
I've only tested with Pandas 0.23.0, so I don't know if |
I took the same error when running code on the environment having Pandas 0.23.0, fbprophet 0.4.post2, Python 3.6.5. |
@lambdu thanks for the great repro. Here is what I have found. In pandas 0.23.0, this code produces the error:
It only produces the error if you include multiple holidays. Both of these work:
None of these produce the error in pandas 0.24.1. I'm not quite sure what is going on yet, but will try to get this figured out tomorrow now that I am able to produce it. |
OK the issue is from this bug in pandas pandas-dev/pandas#21494 which was fixed in 0.23.2. Basically, it throws the error if you do For instance, in pd 0.23.0:
This is because We can mitigate this on the fbprophet side, but in the meantime, the workaround is very easy: Just reset the index on the holidays dataframe before passing it in to fbprophet. This code works in pandas 0.23.0:
|
I'm going to leave this open until we push the fix (we should get it to work in 0.23.0). |
Requirement was updated to pandas 0.23.4 to avoid another not-backwards-compatible pandas change, so that will resolve this once pushed to pypi. |
Pushed to PyPI |
I am still getting "not found in axis" when using |
Could you post the full traceback for when you get the error so I can try and see what is happening? Or even better would be code that produces the error? If you could also verify that you're using the latest version of fbprophet (0.5) that'd be great. |
please! how to fix this problem? |
@elva4012 can you post code that generates the issue? And check the versions of pandas and fbprophet that you're using:
|
I borrowed the example code from https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html df = pd.DataFrame(np.arange(12).reshape(3, 4), NB: newbie been doing pandas a few months. |
the code in the version 0.3 of fbprophet is correct, but in the new version 0.4 throw the next exception.
pandas versio 0.23.0 fbprophet version 0.4.post2 python 3.6
Traceback (most recent call last): File "main.py", line 108, in <module> rlt = predict(vol, dataset) File "main.py", line 84, in predict predict_y = model.predict(forecast_df) File "D:\software\anaconda3\lib\site-packages\fbprophet\forecaster.py", line 1137, in predict seasonal_components = self.predict_seasonal_components(df) File "D:\software\anaconda3\lib\site-packages\fbprophet\forecaster.py", line 1252, in predict_seasonal_components self.make_all_seasonality_features(df) File "D:\software\anaconda3\lib\site-packages\fbprophet\forecaster.py", line 714, in make_all_seasonality_features holidays = self.construct_holiday_dataframe(df['ds']) File "D:\software\anaconda3\lib\site-packages\fbprophet\forecaster.py", line 447, in construct_holiday_dataframe all_holidays = all_holidays.drop(index_to_drop) File "D:\software\anaconda3\lib\site-packages\pandas\core\frame.py", line 3694, in drop errors=errors) File "D:\software\anaconda3\lib\site-packages\pandas\core\generic.py", line 3108, in drop obj = obj._drop_axis(labels, axis, level=level, errors=errors) File "D:\software\anaconda3\lib\site-packages\pandas\core\generic.py", line 3158, in _drop_axis raise KeyError('{} not found in axis'.format(labels)) KeyError: '[] not found in axis'
The text was updated successfully, but these errors were encountered: