series = numpy.array(['1970-01-01', '1970-02-01', '1970-09-01'], dtype='datetime64[D]') series2 = series + numpy.timedelta(1, 'Y') # Add 2 years ^^^
Ops, after reviewing this document, I've discovered a couple of typos. A Tuesday 29 July 2008, Francesc Alted escrigué: [snip] the above line should read:
series2 = series + numpy.timedelta(2, 'Y') # Add 2 years
series2
array(['1972-01-01', '1972-02-01', '1972-09-01'], dtype='datetime64[D]') # the 'D'ay time unit has been chosen
numpy.change_unit( numpy.array([1,2], 'T[Y]'), 'T[d]' )
array([365, 731], dtype="datetime64[d]")
or:
ref = numpy.datetime64('1971', 'T[Y]') numpy.change_unit( numpy.array([1,2], 't[Y]'), 't[d]', ref )
array([366, 365], dtype="timedelta64[d]") ^^^
[snip] the above line should read: array([366, 731], dtype="timedelta64[d]") -- Francesc Alted