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

Skip to content

Commit ea02861

Browse files
authored
Merge pull request #10638 from jklymak/enh-autodecode-pandastimestamp
ENH: check `.values` in more places
2 parents 609e9bf + 59bbccb commit ea02861

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/matplotlib/dates.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,10 @@ def date2num(d):
437437
For details see the module docstring.
438438
"""
439439

440+
if hasattr(d, "values"):
441+
# this unpacks pandas series or dataframes...
442+
d = d.values
443+
440444
if ((isinstance(d, np.ndarray) and np.issubdtype(d.dtype, np.datetime64))
441445
or isinstance(d, np.datetime64)):
442446
return _dt64_to_ordinalf(d)

lib/matplotlib/units.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ def get_converter(self, x):
160160
if classx is not None:
161161
converter = self.get(classx)
162162

163+
if converter is None and hasattr(x, "values"):
164+
# this unpacks pandas series or dataframes...
165+
x = x.values
166+
163167
# If x is an array, look inside the array for data with units
164168
if isinstance(x, np.ndarray) and x.size:
165169
xravel = x.ravel()

0 commit comments

Comments
 (0)