Skip to content

Commit efaadd5

Browse files
charlesdong1991jreback
authored andcommitted
TST: Add test for TypeError when using datetime.time in scatter plot (#30602)
1 parent a9423e3 commit efaadd5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/plotting/test_frame.py

+9
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,15 @@ def test_plot_scatter(self):
11621162
axes = df.plot(x="x", y="y", kind="scatter", subplots=True)
11631163
self._check_axes_shape(axes, axes_num=1, layout=(1, 1))
11641164

1165+
def test_raise_error_on_datetime_time_data(self):
1166+
# GH 8113, datetime.time type is not supported by matplotlib in scatter
1167+
df = pd.DataFrame(np.random.randn(10), columns=["a"])
1168+
df["dtime"] = pd.date_range(start="2014-01-01", freq="h", periods=10).time
1169+
msg = "must be a string or a number, not 'datetime.time'"
1170+
1171+
with pytest.raises(TypeError, match=msg):
1172+
df.plot(kind="scatter", x="dtime", y="a")
1173+
11651174
def test_scatterplot_datetime_data(self):
11661175
# GH 30391
11671176
dates = pd.date_range(start=date(2019, 1, 1), periods=12, freq="W")

0 commit comments

Comments
 (0)