Given a numpy array structure of identical (user specified) objects, is there a way to references all of them at once?
E.g. given a numpy array structure of objects of type date, is there a way to take the average of the years without resorting to a for loop or to +1 to the year attribute of each object in the array?
Example code follows.
from numpy import *
from datetime import *
#this works
A = array([2012, 2011, 2009])
print average(A)
date1 = date(2012,06,30)
date2 = date(2011,06,30)
date3 = date(2010,06,30)
B = array([date1, date2, date3])
print B[0].year
print B[1].year
print B[2].year
#this doesn't
print average(B.year)