Code Sample, a copy-pastable example if possible
from fbprophet import Prophet
import pandas as pd
import numpy as np
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()
Above code is the first time series plotting example in the docs. It throws a type error as follows
TypeError Traceback (most recent call last)
<ipython-input-14-7ea99c00ceb5> in <module>
1 ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
2 ts = ts.cumsum()
----> 3 ts.plot()
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/pandas/plotting/_core.py in __call__(self, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds)
2740 colormap=colormap, table=table, yerr=yerr,
2741 xerr=xerr, label=label, secondary_y=secondary_y,
-> 2742 **kwds)
2743 __call__.__doc__ = plot_series.__doc__
2744
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/pandas/plotting/_core.py in plot_series(data, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds)
1996 yerr=yerr, xerr=xerr,
1997 label=label, secondary_y=secondary_y,
-> 1998 **kwds)
1999
2000
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/pandas/plotting/_core.py in _plot(data, x, y, subplots, ax, kind, **kwds)
1799 plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
1800
-> 1801 plot_obj.generate()
1802 plot_obj.draw()
1803 return plot_obj.result
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/pandas/plotting/_core.py in generate(self)
249 self._compute_plot_data()
250 self._setup_subplots()
--> 251 self._make_plot()
252 self._add_table()
253 self._make_legend()
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/pandas/plotting/_core.py in _make_plot(self)
994 stacking_id=stacking_id,
995 is_errorbar=is_errorbar,
--> 996 **kwds)
997 self._add_legend_handle(newlines[0], label, index=i)
998
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/pandas/plotting/_core.py in _ts_plot(cls, ax, x, data, style, **kwds)
1032 ax._plot_data.append((data, cls._kind, kwds))
1033
-> 1034 lines = cls._plot(ax, data.index, data.values, style=style, **kwds)
1035 # set date formatter, locators and rescale limits
1036 format_dateaxis(ax, ax.freq, data.index)
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/pandas/plotting/_core.py in _plot(cls, ax, x, y, style, column_num, stacking_id, **kwds)
1009 cls._initialize_stacker(ax, stacking_id, len(y))
1010 y_values = cls._get_stacked_values(ax, stacking_id, y, kwds['label'])
-> 1011 lines = MPLPlot._plot(ax, x, y_values, style=style, **kwds)
1012 cls._update_stacker(ax, stacking_id, y)
1013 return lines
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/pandas/plotting/_core.py in _plot(cls, ax, x, y, style, is_errorbar, **kwds)
599 else:
600 args = (x, y)
--> 601 return ax.plot(*args, **kwds)
602
603 def _get_index_name(self):
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/matplotlib/axes/_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
1666 lines = [*self._get_lines(*args, data=data, **kwargs)]
1667 for line in lines:
-> 1668 self.add_line(line)
1669 self.autoscale_view(scalex=scalex, scaley=scaley)
1670 return lines
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/matplotlib/axes/_base.py in add_line(self, line)
1898 line.set_clip_path(self.patch)
1899
-> 1900 self._update_line_limits(line)
1901 if not line.get_label():
1902 line.set_label('_line%d' % len(self.lines))
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/matplotlib/axes/_base.py in _update_line_limits(self, line)
1920 Figures out the data limit of the given line, updating self.dataLim.
1921 """
-> 1922 path = line.get_path()
1923 if path.vertices.size == 0:
1924 return
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/matplotlib/lines.py in get_path(self)
1025 """
1026 if self._invalidy or self._invalidx:
-> 1027 self.recache()
1028 return self._path
1029
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/matplotlib/lines.py in recache(self, always)
668 if always or self._invalidx:
669 xconv = self.convert_xunits(self._xorig)
--> 670 x = _to_unmasked_float_array(xconv).ravel()
671 else:
672 x = self._x
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/matplotlib/cbook/__init__.py in _to_unmasked_float_array(x)
1388 return np.ma.asarray(x, float).filled(np.nan)
1389 else:
-> 1390 return np.asarray(x, float)
1391
1392
/usr/local/anaconda3/envs/order_forecast/lib/python3.7/site-packages/numpy/core/numeric.py in asarray(a, dtype, order)
536
537 """
--> 538 return array(a, dtype, copy=False, order=order)
539
540
TypeError: float() argument must be a string or a number, not 'Period'
[paste the output of pd.show_versions() here below this line]
commit: None
pandas: 0.24.2
pytest: None
pip: 19.1.1
setuptools: 41.0.1
Cython: 0.29.10
numpy: 1.16.4
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.5.0
sphinx: None
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.1.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: 2.7.5 (dt dec pq3 ext lo64)
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
I have the same issue since upgrading to the newest version of fbprophet (0.5). The older version (0.4.post2) works fine.
Try this
# Assuming you have imported Pandas appropriately
pd.plotting.register_matplotlib_converters()
ts.plot()
See #999.
Most helpful comment
Try this
See #999.