I need a function which will take an N by 3 or N by 6

> array, where the columns are year, month, day in the

> first case and those three plus hours, minutes, and

> seconds in the second case and convert them to matplotlib

> dates. This would work the same as the MATLAB datenum()

> function.

Hi Stephen,

How about

from datetime import datetime

from pylab import date2num

x = ...your array

dts = date2num([ datetime(y,m,d) for y,m,d in x ])

or for the Nx6 case

dts = date2num([ datetime(y,m,d,h,min,s) for y,m,d,h,min,s in x ])

or more succinctly

dts = date2num([ datetime(*date) for date in x ])

FYI, date2num is found in matplotlib.dates. I'll take a look at the

matlab datenum docstring in matlab and see about including this

functionality in the matplotlib.dates version.

Cheers,

JDH