Skip to content

Commit 9186cbc

Browse files
committed
ENH: more helpful error message when plotting fails in DataFrame.plot, GH #478
1 parent eaf868c commit 9186cbc

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pandas/core/frame.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,12 +3208,18 @@ def plot(self, subplots=False, sharex=True, sharey=False, use_index=True,
32083208
for i, col in enumerate(_try_sort(self.columns)):
32093209
empty = self[col].count() == 0
32103210
y = self[col].values if not empty else np.zeros(x.shape)
3211-
if subplots:
3212-
ax = axes[i]
3213-
ax.plot(x, y, 'k', label=str(col), **kwds)
3214-
ax.legend(loc='best')
3215-
else:
3216-
ax.plot(x, y, label=str(col), **kwds)
3211+
3212+
try:
3213+
if subplots:
3214+
ax = axes[i]
3215+
ax.plot(x, y, 'k', label=str(col), **kwds)
3216+
ax.legend(loc='best')
3217+
else:
3218+
ax.plot(x, y, label=str(col), **kwds)
3219+
except Exception, e:
3220+
msg = ('Unable to plot data %s vs index %s,\n'
3221+
'error was: %s' % (str(y), str(x), str(e)))
3222+
raise Exception(msg)
32173223

32183224
ax.grid(grid)
32193225

0 commit comments

Comments
 (0)