Skip to content

Commit 2e7f5a3

Browse files
authored
CLN use pd.Timestamp for single element in converter (#49148)
1 parent a75ea75 commit 2e7f5a3

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

doc/source/whatsnew/v2.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ Period
258258

259259
Plotting
260260
^^^^^^^^
261-
-
261+
- ``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`)
262262
-
263263

264264
Groupby/resample/rolling

pandas/plotting/_matplotlib/converter.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ def _to_ordinalf(tm: pydt.time) -> float:
152152

153153
def time2num(d):
154154
if isinstance(d, str):
155-
parsed = tools.to_datetime(d)
156-
if not isinstance(parsed, datetime):
157-
raise ValueError(f"Could not parse time {d}")
155+
parsed = Timestamp(d)
158156
return _to_ordinalf(parsed.time())
159157
if isinstance(d, pydt.time):
160158
return _to_ordinalf(d)

0 commit comments

Comments
 (0)