-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
TypeError: cannot astype a timedelta from [timedelta64[ns]] to [int32] #593
Comments
Hi, @andymancodes the exactly same 'TypeError' appeared when I ran the same code. So if you just want to plot the error, maybe you could try to plot it with pd.DataFrame.plot(), it's not as pretty as the 'original ' output figure, but it work. May this would help. |
@FGGsysu Hi, I am not getting how the evaluation of the model is goining on. I have set my horizon to 30 days, yet I get I get: horizon mape
How to plot the error now? What does it mean? Any help would be wonderful! Thanks. |
I'm going to leave this open until we push the next version to pip which will have this fix. |
I have latest fbprophet package and I am having this issue as well, and I am on 64-bit system. I even manually went into plot.py and modified lines 464 and 465 to use .astype(np.int64) , and still no luck. Error continues saying: |
@ajoros we just pushed a new version (0.4) to PyPI that should fix this. Could you re-install fbprophet and check if it works now?
|
The fix has been pushed to PyPI so I'll close this, but @ajoros keep me posted so we can make sure it is working in your case. |
Hi,
while trying to run: fig = plot_cross_validation_metric(df_cv, metric='mape')
I am getting:
TypeError Traceback (most recent call last)
in ()
----> 1 fig = plot_cross_validation_metric(df_cv, metric='mape')
C:\Program Files\Anaconda3\envs\py35\lib\site-packages\fbprophet\plot.py in plot_cross_validation_metric(df_cv, metric, rolling_window, ax)
462 break
463
--> 464 x_plt = df_none['horizon'].astype('timedelta64[ns]').astype(int) / float(dt_conversions[i])
465 x_plt_h = df_h['horizon'].astype('timedelta64[ns]').astype(int) / float(dt_conversions[i])
466
C:\Program Files\Anaconda3\envs\py35\lib\site-packages\pandas\util_decorators.py in wrapper(*args, **kwargs)
176 else:
177 kwargs[new_arg_name] = new_arg_value
--> 178 return func(*args, **kwargs)
179 return wrapper
180 return _deprecate_kwarg
C:\Program Files\Anaconda3\envs\py35\lib\site-packages\pandas\core\generic.py in astype(self, dtype, copy, errors, **kwargs)
4995 # else, only a single dtype is given
4996 new_data = self._data.astype(dtype=dtype, copy=copy, errors=errors,
-> 4997 **kwargs)
4998 return self._constructor(new_data).finalize(self)
4999
C:\Program Files\Anaconda3\envs\py35\lib\site-packages\pandas\core\internals.py in astype(self, dtype, **kwargs)
3712
3713 def astype(self, dtype, **kwargs):
-> 3714 return self.apply('astype', dtype=dtype, **kwargs)
3715
3716 def convert(self, **kwargs):
C:\Program Files\Anaconda3\envs\py35\lib\site-packages\pandas\core\internals.py in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs)
3579
3580 kwargs['mgr'] = self
-> 3581 applied = getattr(b, f)(**kwargs)
3582 result_blocks = _extend_blocks(applied, result_blocks)
3583
C:\Program Files\Anaconda3\envs\py35\lib\site-packages\pandas\core\internals.py in astype(self, dtype, copy, errors, values, **kwargs)
573 def astype(self, dtype, copy=False, errors='raise', values=None, **kwargs):
574 return self._astype(dtype, copy=copy, errors=errors, values=values,
--> 575 **kwargs)
576
577 def _astype(self, dtype, copy=False, errors='raise', values=None,
C:\Program Files\Anaconda3\envs\py35\lib\site-packages\pandas\core\internals.py in _astype(self, dtype, copy, errors, values, klass, mgr, **kwargs)
662
663 # _astype_nansafe works fine with 1-d only
--> 664 values = astype_nansafe(values.ravel(), dtype, copy=True)
665 values = values.reshape(self.shape)
666
C:\Program Files\Anaconda3\envs\py35\lib\site-packages\pandas\core\dtypes\cast.py in astype_nansafe(arr, dtype, copy)
694 raise TypeError("cannot astype a timedelta from [{from_dtype}] "
695 "to [{to_dtype}]".format(from_dtype=arr.dtype,
--> 696 to_dtype=dtype))
697
698 elif (np.issubdtype(arr.dtype, np.floating) and
TypeError: cannot astype a timedelta from [timedelta64[ns]] to [int32]
While, df_p = performance_metrics(df_cv) works perfectly fine.
I really need to plot the error.
The text was updated successfully, but these errors were encountered: