Skip to content

Commit 1c8891e

Browse files
committed
ENH/API: remove raise_on_error in plotting functions
trivial doc fix note the docs revert back
1 parent 2f4cd4b commit 1c8891e

File tree

4 files changed

+38
-49
lines changed

4 files changed

+38
-49
lines changed

RELEASE.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ pandas 0.11.1
6868
thanks @hoechenberger
6969
- ``read_html`` no longer performs hard date conversion
7070
- Plotting functions now raise a ``TypeError`` before trying to plot anything
71-
if the associated objects have have a dtype of ``object`` (GH1818_). This
72-
happens before any drawing takes place which elimnates any spurious plots
73-
from showing up.
71+
if the associated objects have have a dtype of ``object`` (GH1818_,
72+
GH3572_). This happens before any drawing takes place which elimnates any
73+
spurious plots from showing up.
7474

7575
**API Changes**
7676

@@ -93,6 +93,9 @@ pandas 0.11.1
9393
- Raise on ``iloc`` when boolean indexing with a label based indexer mask
9494
e.g. a boolean Series, even with integer labels, will raise. Since ``iloc``
9595
is purely positional based, the labels on the Series are not alignable (GH3631_)
96+
- The ``raise_on_error`` option to plotting methods is obviated by GH3572_,
97+
so it is removed. Plots now always raise when data cannot be plotted or the
98+
object being plotted has a dtype of ``object``.
9699

97100
**Bug Fixes**
98101

@@ -232,6 +235,7 @@ pandas 0.11.1
232235
.. _GH3649: https://github.com/pydata/pandas/issues/3649
233236
.. _Gh3616: https://github.com/pydata/pandas/issues/3616
234237
.. _GH1818: https://github.com/pydata/pandas/issues/1818
238+
.. _GH3572: https://github.com/pydata/pandas/issues/3572
235239

236240
pandas 0.11.0
237241
=============

doc/source/v0.11.1.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ API changes
6161

6262
``df.iloc[mask]`` will raise a ``ValueError``
6363

64+
- The ``raise_on_error`` argument to plotting functions is removed. Instead,
65+
plotting functions raise a ``TypeError`` when the ``dtype`` of the object
66+
is ``object`` to remind you to avoid ``object`` arrays whenever possible
67+
and thus you should cast to an appropriate numeric dtype if you need to
68+
plot something.
69+
6470

6571

6672
Enhancements
@@ -119,7 +125,7 @@ Enhancements
119125

120126
The last element yielded by the iterator will be a ``Series`` containing
121127
the last element of the longest string in the ``Series`` with all other
122-
elements being ``NaN``. Here since ``'slow`` is the longest string
128+
elements being ``NaN``. Here since ``'slow'`` is the longest string
123129
and there are no other strings with the same length ``'w'`` is the only
124130
non-null string in the yielded ``Series``.
125131

@@ -160,9 +166,9 @@ Enhancements
160166
to specify custom column names of the returned DataFrame.
161167

162168
- Plotting functions now raise a ``TypeError`` before trying to plot anything
163-
if the associated objects have have a ``dtype`` of ``object`` (GH1818_).
164-
This happens before any drawing takes place which elimnates any spurious
165-
plots from showing up.
169+
if the associated objects have have a ``dtype`` of ``object`` (GH1818_,
170+
GH3572_). This happens before any drawing takes place which elimnates any
171+
spurious plots from showing up.
166172

167173
Bug Fixes
168174
~~~~~~~~~
@@ -234,3 +240,4 @@ on GitHub for a complete list.
234240
.. _GH3606: https://github.com/pydata/pandas/issues/3606
235241
.. _GH3656: https://github.com/pydata/pandas/issues/3656
236242
.. _GH1818: https://github.com/pydata/pandas/issues/1818
243+
.. _GH3572: https://github.com/pydata/pandas/issues/3572

pandas/tools/plotting.py

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,8 @@ class MPLPlot(object):
700700
"""
701701
_default_rot = 0
702702

703-
_pop_attributes = ['label', 'style', 'logy', 'logx', 'loglog',
704-
'raise_on_error']
705-
_attr_defaults = {'logy': False, 'logx': False, 'loglog': False,
706-
'raise_on_error': True}
703+
_pop_attributes = ['label', 'style', 'logy', 'logx', 'loglog']
704+
_attr_defaults = {'logy': False, 'logx': False, 'loglog': False}
707705

708706
def __init__(self, data, kind=None, by=None, subplots=False, sharex=True,
709707
sharey=False, use_index=True,
@@ -1203,27 +1201,17 @@ def _make_plot(self):
12031201
else:
12041202
args = (ax, x, y, style)
12051203

1206-
try:
1207-
newline = plotf(*args, **kwds)[0]
1208-
lines.append(newline)
1209-
leg_label = label
1210-
if self.mark_right and self.on_right(i):
1211-
leg_label += ' (right)'
1212-
labels.append(leg_label)
1213-
ax.grid(self.grid)
1214-
1215-
if self._is_datetype():
1216-
left, right = _get_xlim(lines)
1217-
ax.set_xlim(left, right)
1218-
except AttributeError as inst: # non-numeric
1219-
msg = ('Unable to plot data %s vs index %s,\n'
1220-
'error was: %s' % (str(y), str(x), str(inst)))
1221-
if not self.raise_on_error:
1222-
print msg
1223-
else:
1224-
msg = msg + ('\nConsider setting raise_on_error=False'
1225-
'to suppress')
1226-
raise TypeError(msg)
1204+
newline = plotf(*args, **kwds)[0]
1205+
lines.append(newline)
1206+
leg_label = label
1207+
if self.mark_right and self.on_right(i):
1208+
leg_label += ' (right)'
1209+
labels.append(leg_label)
1210+
ax.grid(self.grid)
1211+
1212+
if self._is_datetype():
1213+
left, right = _get_xlim(lines)
1214+
ax.set_xlim(left, right)
12271215

12281216
self._make_legend(lines, labels)
12291217

@@ -1242,22 +1230,12 @@ def to_leg_label(label, i):
12421230
return label
12431231

12441232
def _plot(data, col_num, ax, label, style, **kwds):
1245-
try:
1246-
newlines = tsplot(data, plotf, ax=ax, label=label,
1247-
style=style, **kwds)
1248-
ax.grid(self.grid)
1249-
lines.append(newlines[0])
1250-
leg_label = to_leg_label(label, col_num)
1251-
labels.append(leg_label)
1252-
except AttributeError as inst: #non-numeric
1253-
msg = ('Unable to plot %s,\n'
1254-
'error was: %s' % (str(data), str(inst)))
1255-
if not self.raise_on_error:
1256-
print msg
1257-
else:
1258-
msg = msg + ('\nConsider setting raise_on_error=False'
1259-
'to suppress')
1260-
raise TypeError(msg)
1233+
newlines = tsplot(data, plotf, ax=ax, label=label,
1234+
style=style, **kwds)
1235+
ax.grid(self.grid)
1236+
lines.append(newlines[0])
1237+
leg_label = to_leg_label(label, col_num)
1238+
labels.append(leg_label)
12611239

12621240
if isinstance(data, Series):
12631241
ax = self._get_ax(0) # self.axes[0]

pandas/tseries/tests/test_plotting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_nonnumeric_exclude(self):
8989
df = DataFrame({'A': ["x", "y", "z"], 'B': [1,2,3]}, idx)
9090

9191
plt.close('all')
92-
ax = df.plot(raise_on_error=False) # it works
92+
ax = df.plot() # it works
9393
self.assert_(len(ax.get_lines()) == 1) #B was plotted
9494

9595
plt.close('all')

0 commit comments

Comments
 (0)