Skip to content

Commit 99da02e

Browse files
committed
Better error message for DataFrame.hist() without numerical columns (pandas-dev#10444)
1 parent 576f0a8 commit 99da02e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/plotting/test_hist_method.py

+10
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,16 @@ def test_hist_df_legacy(self):
209209
with pytest.raises(AttributeError):
210210
ser.hist(foo='bar')
211211

212+
@pytest.mark.slow
213+
def test_hist_non_numerical(self):
214+
# check non-numerical df raises appropriate exception and error message
215+
df = DataFrame(np.random.rand(10, 2))
216+
df_o = df.astype(np.object)
217+
218+
msg = "hist method requires numerical columns, nothing to plot."
219+
with pytest.raises(ValueError, match=msg):
220+
df_o.hist()
221+
212222
@pytest.mark.slow
213223
def test_hist_layout(self):
214224
df = DataFrame(randn(100, 3))

0 commit comments

Comments
 (0)