Skip to content

More helpful error message when DataFrame.plot fails on some column #478

@mattharrison

Description

@mattharrison

I'm trying to plot a DataFrame and it wasn't working, so I tried loading the data set from the read_csv docs. It also failed. I think I'm missing something, but I've been successful with matplotlib before. :)

from pandas import read_csv import matplotlib.pyplot as plt junk = read_csv('bar.csv') fig = plt.figure() junk.plot() fig.savefig('/tmp/foo3.png') 

bar.csv

year,indiv,zit,xit 1977,"A",1.2,.6 1977,"B",1.5,.5 1977,"C",1.7,.8 1978,"A",.2,.06 1978,"B",.7,.2 1978,"C",.8,.3 1978,"D",.9,.5 1978,"E",1.4,.9 1979,"C",.2,.15 1979,"D",.14,.05 1979,"E",.5,.15 1979,"F",1.2,.5 1979,"G",3.4,1.9 1979,"H",5.4,2.7 1979,"I",6.4,1.2 

I get the folowing error:

python /tmp/plot.py Traceback (most recent call last): File "/tmp/plot.py", line 6, in <module> junk.plot() File "/home/mharrison/work/pandas/env/lib/python2.6/site-packages/pandas/core/frame.py", line 3225, in plot ax.plot(x, y, label=str(col), **kwds) File "/home/mharrison/work/pandas/env/lib/python2.6/site-packages/matplotlib/axes.py", line 3783, in plot for line in self._get_lines(*args, **kwargs): File "/home/mharrison/work/pandas/env/lib/python2.6/site-packages/matplotlib/axes.py", line 317, in _grab_next_args for seg in self._plot_args(remaining, kwargs): File "/home/mharrison/work/pandas/env/lib/python2.6/site-packages/matplotlib/axes.py", line 275, in _plot_args linestyle, marker, color = _process_plot_format(tup[-1]) File "/home/mharrison/work/pandas/env/lib/python2.6/site-packages/matplotlib/axes.py", line 93, in _process_plot_format if fmt.find('--')>=0: AttributeError: 'numpy.ndarray' object has no attribute 'find' 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions