Commit 16edaaf 1 parent 8117460 commit 16edaaf Copy full SHA for 16edaaf
File tree 5 files changed +19
-10
lines changed
5 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ Performance Improvements
121
121
Bug Fixes
122
122
~~~~~~~~~
123
123
- Bug in :func: `to_datetime ` which would raise an (incorrect) ``ValueError `` when called with a date far into the future and the ``format `` argument specified instead of raising ``OutOfBoundsDatetime `` (:issue: `23830 `)
124
- -
124
+ - Bug in an error message in :meth: ` DataFrame.plot `. Improved the error message if non-numerics are passed to :meth: ` DataFrame.plot ` ( :issue: ` 25481 `)
125
125
-
126
126
127
127
Categorical
Original file line number Diff line number Diff line change @@ -361,10 +361,9 @@ def _compute_plot_data(self):
361
361
except AttributeError :
362
362
is_empty = not len (numeric_data )
363
363
364
- # no empty frames or series allowed
364
+ # no non-numeric frames or series allowed
365
365
if is_empty :
366
- raise TypeError ('Empty {0!r}: no numeric data to '
367
- 'plot' .format (numeric_data .__class__ .__name__ ))
366
+ raise TypeError ('no numeric data to plot' )
368
367
369
368
self .data = numeric_data
370
369
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ def test_nonnumeric_exclude(self):
97
97
assert len (ax .get_lines ()) == 1 # B was plotted
98
98
self .plt .close (fig )
99
99
100
- msg = "Empty 'DataFrame': no numeric data to plot"
100
+ msg = "no numeric data to plot"
101
101
with pytest .raises (TypeError , match = msg ):
102
102
df ['A' ].plot ()
103
103
Original file line number Diff line number Diff line change @@ -485,7 +485,9 @@ def test_subplots_timeseries_y_axis(self):
485
485
ax_datetime_all_tz = testdata .plot (y = "datetime_all_tz" )
486
486
assert (ax_datetime_all_tz .get_lines ()[0 ].get_data ()[1 ] ==
487
487
testdata ["datetime_all_tz" ].values ).all ()
488
- with pytest .raises (TypeError ):
488
+
489
+ msg = "no numeric data to plot"
490
+ with pytest .raises (TypeError , match = msg ):
489
491
testdata .plot (y = "text" )
490
492
491
493
@pytest .mark .xfail (reason = 'not support for period, categorical, '
@@ -2219,7 +2221,9 @@ def test_all_invalid_plot_data(self):
2219
2221
for kind in plotting ._core ._common_kinds :
2220
2222
if not _ok_for_gaussian_kde (kind ):
2221
2223
continue
2222
- with pytest .raises (TypeError ):
2224
+
2225
+ msg = "no numeric data to plot"
2226
+ with pytest .raises (TypeError , match = msg ):
2223
2227
df .plot (kind = kind )
2224
2228
2225
2229
@pytest .mark .slow
@@ -2230,7 +2234,9 @@ def test_partially_invalid_plot_data(self):
2230
2234
for kind in plotting ._core ._common_kinds :
2231
2235
if not _ok_for_gaussian_kde (kind ):
2232
2236
continue
2233
- with pytest .raises (TypeError ):
2237
+
2238
+ msg = "no numeric data to plot"
2239
+ with pytest .raises (TypeError , match = msg ):
2234
2240
df .plot (kind = kind )
2235
2241
2236
2242
with tm .RNGContext (42 ):
Original file line number Diff line number Diff line change @@ -706,7 +706,9 @@ def test_invalid_plot_data(self):
706
706
for kind in plotting ._core ._common_kinds :
707
707
if not _ok_for_gaussian_kde (kind ):
708
708
continue
709
- with pytest .raises (TypeError ):
709
+
710
+ msg = "no numeric data to plot"
711
+ with pytest .raises (TypeError , match = msg ):
710
712
s .plot (kind = kind , ax = ax )
711
713
712
714
@pytest .mark .slow
@@ -723,7 +725,9 @@ def test_partially_invalid_plot_data(self):
723
725
for kind in plotting ._core ._common_kinds :
724
726
if not _ok_for_gaussian_kde (kind ):
725
727
continue
726
- with pytest .raises (TypeError ):
728
+
729
+ msg = "no numeric data to plot"
730
+ with pytest .raises (TypeError , match = msg ):
727
731
s .plot (kind = kind , ax = ax )
728
732
729
733
def test_invalid_kind (self ):
You can’t perform that action at this time.
0 commit comments