Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 333b2ea

Browse files
committed
ENH: autodecode pandas timestamps
1 parent d2e68ff commit 333b2ea

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/matplotlib/dates.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@ def date2num(d):
430430
For details see the module docstring.
431431
"""
432432

433+
if hasattr(d, "values"):
434+
d = d.values
435+
if hasattr(d, "to_pydatetime"):
436+
d = d.to_pydatetime()
437+
433438
if ((isinstance(d, np.ndarray) and np.issubdtype(d.dtype, np.datetime64))
434439
or isinstance(d, np.datetime64)):
435440
return _dt64_to_ordinalf(d)

lib/matplotlib/units.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ def get_converter(self, x):
154154
# DISABLED cached = self._cached.get(idx)
155155
# DISABLED if cached is not None: return cached
156156

157+
if hasattr(x, "values"):
158+
x = x.values
159+
if hasattr(x, "to_pydatetime"):
160+
x = x.to_pydatetime()
161+
157162
converter = None
158163
classx = getattr(x, '__class__', None)
159164

0 commit comments

Comments
 (0)