-
- Notifications
You must be signed in to change notification settings - Fork 19.2k
Description
Code Sample
import pandas as pd from pandas.compat import StringIO import matplotlib.pyplot as plt dat = """c1,c2,c3 1000,2000,1500 9000,8000,1600""" df = pd.read_csv(StringIO(dat)) print(df) df.plot.bar() plt.show() df = df.apply(lambda x: pd.to_timedelta(x, unit='ms')) print(df) df.plot.bar() plt.show()Problem description
plot.bar() works with numerical values (int, float).
c1 c2 c3 0 1000 2000 1500 1 9000 8000 1600 not with Timedelta
c1 c2 c3 0 00:00:01 00:00:02 00:00:01.500000 1 00:00:09 00:00:08 00:00:01.600000 df.plot.bar() File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 2659, in bar return self(kind='bar', x=x, y=y, **kwds) File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 2620, in __call__ sort_columns=sort_columns, **kwds) File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 1857, in plot_frame **kwds) File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 1682, in _plot plot_obj.generate() File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 236, in generate self._compute_plot_data() File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 345, in _compute_plot_data 'plot'.format(numeric_data.__class__.__name__)) TypeError: Empty 'DataFrame': no numeric data to plot Expected Output
Timedelta on y axis should be displayed
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Darwin
OS-release: 16.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: fr_FR.UTF-8
LOCALE: fr_FR.UTF-8
pandas: 0.20.1
pytest: 3.1.2
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.19.0
xarray: 0.9.5
IPython: 5.3.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.3.0
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.7
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.3
bs4: 4.6.0
html5lib: 0.999
sqlalchemy: 1.1.9
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: 0.4.0
