Skip to content

TST: Add test for TypeError when using datetime.time in scatter plot #30602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pandas/tests/plotting/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,15 @@ def test_plot_scatter(self):
axes = df.plot(x="x", y="y", kind="scatter", subplots=True)
self._check_axes_shape(axes, axes_num=1, layout=(1, 1))

def test_raise_error_on_datetime_time_data(self):
# GH 8113, datetime.time type is not supported by matplotlib in scatter
df = pd.DataFrame(np.random.randn(10), columns=["a"])
df["dtime"] = pd.date_range(start="2014-01-01", freq="h", periods=10).time
msg = "must be a string or a number, not 'datetime.time'"

with pytest.raises(TypeError, match=msg):
df.plot(kind="scatter", x="dtime", y="a")

def test_scatterplot_datetime_data(self):
# GH 30391
dates = pd.date_range(start=date(2019, 1, 1), periods=12, freq="W")
Expand Down