I have a numpy array roughly like so:
data
array([(datetime.datetime(2009, 1, 6, 2, 30), 17924.0, 0.0),....
(datetime.datetime(2009, 1, 29, 16, 30), 35249.2, 521.25],
dtype=[('timestamp', '|O4'), ('x1', '<f8'), ('x2', '<f8')])
I would like to be able to index the data based on the first column (i.e. with the datetime objects), so I can access a particular year / month / day worth of data, with something like this:
data[data['timestamp'].year == 2009]
This obviously doesn't work. The only thing I can think of doing is adding additional columns (e.g. a "year" column), so this would work:
data[data['year'] == 2009]
Seems like a fairly inefficient way of doing things (and would duplicate a lot of data) - particularly if I want to index on all the other time intervals as well... is there a better way to do this?
Thanks in advance.