From 79b26d144c0c1ff99c75bef8ef41c6a49eb58155 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Mon, 17 Oct 2022 12:03:04 +0100 Subject: [PATCH 1/3] use pd.Timestamp for single element --- pandas/plotting/_matplotlib/converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/plotting/_matplotlib/converter.py b/pandas/plotting/_matplotlib/converter.py index 6eb77b63f5356..0adfde982e5c2 100644 --- a/pandas/plotting/_matplotlib/converter.py +++ b/pandas/plotting/_matplotlib/converter.py @@ -152,7 +152,7 @@ def _to_ordinalf(tm: pydt.time) -> float: def time2num(d): if isinstance(d, str): - parsed = tools.to_datetime(d) + parsed = Timestamp(d) if not isinstance(parsed, datetime): raise ValueError(f"Could not parse time {d}") return _to_ordinalf(parsed.time()) From bf919fe3ea044d123c0db4a5da572c5ee6187bde Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Mon, 17 Oct 2022 14:35:46 +0100 Subject: [PATCH 2/3] :pencil: add whatsnew entry --- doc/source/whatsnew/v2.0.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index fea3d70d81554..cbc493e1e556d 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -253,7 +253,7 @@ Period Plotting ^^^^^^^^ -- +- ``ax.set_xlim`` was sometimes raising ``UserWarning`` which users couldn't address due to ``set_xlim`` not accepting parsing arguments - the converter now uses :func:`Timestamp` instead (:issue:`49148`) - Groupby/resample/rolling From add99fd5f8463fc3e9153b7e79d258fdbf397440 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <> Date: Mon, 17 Oct 2022 15:37:59 +0100 Subject: [PATCH 3/3] remove unreachable line --- pandas/plotting/_matplotlib/converter.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandas/plotting/_matplotlib/converter.py b/pandas/plotting/_matplotlib/converter.py index 0adfde982e5c2..70fca27c837f3 100644 --- a/pandas/plotting/_matplotlib/converter.py +++ b/pandas/plotting/_matplotlib/converter.py @@ -153,8 +153,6 @@ def _to_ordinalf(tm: pydt.time) -> float: def time2num(d): if isinstance(d, str): parsed = Timestamp(d) - if not isinstance(parsed, datetime): - raise ValueError(f"Could not parse time {d}") return _to_ordinalf(parsed.time()) if isinstance(d, pydt.time): return _to_ordinalf(d)