I have an array of datetime64 type:
dates = np.datetime64(['2010-10-17', '2011-05-13', "2012-01-15"])
Is there a better way than looping through each element just to get np.array of years:
years = f(dates)
#output:
array([2010, 2011, 2012], dtype=int8) #or dtype = string
I'm using stable numpy version 1.6.2.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…