[Tutor] Datetime Integers
Jeremy Traurig
jeremy.traurig at gmail.com
Mon May 21 17:47:56 CEST 2012
Hello,
Is there a module available for python to convert datetime into an
array of integers. For example, I have date where the first column is
a datetime string (i.e. '2010-10-10 01:10:00') and I would like to
convert that into an array with 5 columns corresponding to the integer
values of Year,Month,Day,Hour,Minute. There is a function in Matlab
that performs called datevec() that performs this operation. I find it
much easier to index datetime or perform calculations on other data
when date and time are integers. For example, i generally need to
calculate averages, std, etc based on specific months, years, days,
and hours. Those calculations are extremely simple when I can index an
array of datetime integers. If there is no module to convert datetime
to an array of integers, does anyone have an example of how i might
index datetime using python datetime or numpy datetime64? In each
case, I would need an array of datetime the same dimension as my data
array.
thanks -- jeremy
More information about the Tutor
mailing list