diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index b3fa42477ad2..0a3d8b3d477b 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -430,6 +430,10 @@ def date2num(d): For details see the module docstring. """ + if hasattr(d, "values"): + # this unpacks pandas series or dataframes... + d = d.values + if ((isinstance(d, np.ndarray) and np.issubdtype(d.dtype, np.datetime64)) or isinstance(d, np.datetime64)): return _dt64_to_ordinalf(d) diff --git a/lib/matplotlib/units.py b/lib/matplotlib/units.py index 0df465430b46..cab3967189f7 100644 --- a/lib/matplotlib/units.py +++ b/lib/matplotlib/units.py @@ -160,6 +160,10 @@ def get_converter(self, x): if classx is not None: converter = self.get(classx) + if converter is None and hasattr(x, "values"): + # this unpacks pandas series or dataframes... + x = x.values + # If x is an array, look inside the array for data with units if isinstance(x, np.ndarray) and x.size: xravel = x.ravel()
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: