[SciPy-user] Converting arrays to dates for plot_date()

Dharhas Pothina Dharhas.Pothina@twdb.state.tx...
Fri May 2 07:21:14 CDT 2008

Thank you John, I tried that and got the error message :

TypeError: descriptor 'date' requires a 'datetime.datetime' object but received a 'numpy.float64'

but using datetime() rather than datetime.date() seems to work.

fyi. y'all have a great community here. I've asked two questions in the last few days and was answered quickly and correctly on both occasions.


- dharhas

>>> "John Hunter" <jdh2358@gmail.com> 05/01/08 3:49 PM >>>
On Thu, May 1, 2008 at 3:15 PM, Dharhas Pothina
<Dharhas.Pothina@twdb.state.tx.us> wrote:

>  to generate the list of dates for plot_date()
>  but I can't work out how to convert
>  year = array([2006.0,2007.0])
>  month = array([11,12])
>  day = array([1,2])

dates = [datetime.date(y,m,d) for y,m,d in zip(year, month, day)]
plot(dates, data)  # requires 0.91.2 or svn -- else use date2num and plot_date

SciPy-user mailing list

More information about the SciPy-user mailing list