I'm using matplotlib.dates to convert my string dates into date objects thinking it would be easier to manipulate later.
import matplotlib.dates as md
def ConvertDate(datestr):
'''
Convert string date into matplotlib date object
'''
datefloat = md.datestr2num(datestr)
return md.num2date(datefloat)
What I was trying to do was filter my structured array to tell me the index numbers of rows belong to a certain month and/or year
import numpy as np
np.where( data['date'] == 2008 )
I can probably use a lambda function to convert each object into string value like so
lambda x: x.strftime('%Y')
to compare each item but I dont know where to put this lambda function into np.where or if its even possible.
Any ideas? Or is there some better way to do this?