-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
Description
Code Sample, a copy-pastable example if possible
import pandas as pd
import numpy as np
from pandas.plotting import deregister_matplotlib_converters
deregister_matplotlib_converters()
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts.plot()
~/sandbox/pandas/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)
808 colormap=colormap, table=table, yerr=yerr,
809 xerr=xerr, label=label, secondary_y=secondary_y,
--> 810 **kwds)
811 __call__.__doc__ = plot_series.__doc__
812
~/sandbox/pandas/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)
766 yerr=yerr, xerr=xerr,
767 label=label, secondary_y=secondary_y,
--> 768 **kwds)
769
770
~/sandbox/pandas/pandas/plotting/_core.py in _plot(data, x, y, subplots, ax, kind, **kwds)
714 plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
715
--> 716 plot_obj.generate()
717 plot_obj.draw()
718 return plot_obj.result
~/sandbox/pandas/pandas/plotting/_matplotlib/core.py in generate(self)
214 self._compute_plot_data()
215 self._setup_subplots()
--> 216 self._make_plot()
217 self._add_table()
218 self._make_legend()
~/sandbox/pandas/pandas/plotting/_matplotlib/core.py in _make_plot(self)
987 stacking_id=stacking_id,
988 is_errorbar=is_errorbar,
--> 989 **kwds)
990 self._add_legend_handle(newlines[0], label, index=i)
991
~/sandbox/pandas/pandas/plotting/_matplotlib/core.py in _ts_plot(cls, ax, x, data, style, **kwds)
1025 ax._plot_data.append((data, cls._kind, kwds))
1026
-> 1027 lines = cls._plot(ax, data.index, data.values, style=style, **kwds)
1028 # set date formatter, locators and rescale limits
1029 format_dateaxis(ax, ax.freq, data.index)
~/sandbox/pandas/pandas/plotting/_matplotlib/core.py in _plot(cls, ax, x, y, style, column_num, stacking_id, **kwds)
1002 cls._initialize_stacker(ax, stacking_id, len(y))
1003 y_values = cls._get_stacked_values(ax, stacking_id, y, kwds['label'])
-> 1004 lines = MPLPlot._plot(ax, x, y_values, style=style, **kwds)
1005 cls._update_stacker(ax, stacking_id, y)
1006 return lines
~/sandbox/pandas/pandas/plotting/_matplotlib/core.py in _plot(cls, ax, x, y, style, is_errorbar, **kwds)
581 else:
582 args = (x, y)
--> 583 return ax.plot(*args, **kwds)
584
585 def _get_index_name(self):
~/Envs/pandas-dev/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
~/Envs/pandas-dev/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))
~/Envs/pandas-dev/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
~/Envs/pandas-dev/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
~/Envs/pandas-dev/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
~/Envs/pandas-dev/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
~/Envs/pandas-dev/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'
Problem description
Above code is the first time series plotting example in the docs. It throws a type error as follows
[paste the output of pd.show_versions()
here below this line]
INSTALLED VERSIONS
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