Closed
Description
After updating matplotlib from master yesterday, calling dates.date2num
on either a Pandas Series or a numpy array of numpy.datetime64 types raises an AttributeError
:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-16-9050e29ead3a> in <module>()
1 data = dataset[dataset.sma=='SE']
2 time = data.st_time
----> 3 dates.date2num(time[data.active==0].values)
/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-intel.egg/matplotlib/dates.pyc in date2num(d)
292 if not d.size:
293 return d
--> 294 return _to_ordinalf_np_vectorized(d)
295
296
/Library/Python/2.7/site-packages/numpy-1.8.0.dev_b307a8a_20130729-py2.7-macosx-10.8-intel.egg/numpy/lib/function_base.pyc in __call__(self, *args, **kwargs)
1896 vargs.extend([kwargs[_n] for _n in names])
1897
-> 1898 return self._vectorize_call(func=func, args=vargs)
1899
1900 def _get_ufunc_and_otypes(self, func, args):
/Library/Python/2.7/site-packages/numpy-1.8.0.dev_b307a8a_20130729-py2.7-macosx-10.8-intel.egg/numpy/lib/function_base.pyc in _vectorize_call(self, func, args)
1956 _res = func()
1957 else:
-> 1958 ufunc, otypes = self._get_ufunc_and_otypes(func=func, args=args)
1959
1960 # Convert args to object arrays first
/Library/Python/2.7/site-packages/numpy-1.8.0.dev_b307a8a_20130729-py2.7-macosx-10.8-intel.egg/numpy/lib/function_base.pyc in _get_ufunc_and_otypes(self, func, args)
1920 # arrays (the input values are not checked to ensure this)
1921 inputs = [asarray(_a).flat[0] for _a in args]
-> 1922 outputs = func(*inputs)
1923
1924 # Performance note: profiling indicates that -- for simple functions
/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-intel.egg/matplotlib/dates.pyc in _to_ordinalf(dt)
195 dt -= delta
196
--> 197 base = float(dt.toordinal())
198 if hasattr(dt, 'hour'):
199 base += (dt.hour / HOURS_PER_DAY + dt.minute / MINUTES_PER_DAY +
AttributeError: 'numpy.datetime64' object has no attribute 'toordinal'
The data looks like this:
In[18: time[:4]
Out[18]:
95 2010-04-12 07:23:12
96 2010-06-10 20:43:07
100 2010-06-21 06:37:28
221 2009-07-20 06:53:38
Name: st_time, dtype: datetime64[ns]
This worked prior to the update. Running yesterday's master on OS X 10.8.4 and Python 2.7.2.