Some Matplotlib methods need 'float days format' days . datestr2num is a converter function for this, but it crashes with the corresponding pandas objects:
In [3]: type(df.index) Out[3]: pandas.tseries.index.DatetimeIndex In [4]: type(df.index[0]) Out[4]: pandas.tslib.Timestamp In [5]: mpl.dates.date2num(df.index) Out [5]: ... AttributeError: 'numpy.datetime64' object has no attribute 'toordinal'
This gives a useful list of times in the "float days" format:
dates = [mpl.dates.date2num(t) for t in df.index]
But is there a better way?
source share