I have a list of events that occur at mS accurate intervals, that spans a few days. I want to cluster all the events that occur in a 'per-n-minutes' slot (can be twenty events, can be no events). I have a datetime.datetime
item for each event, so I can get datetime.datetime.minute
without any trouble.
My list of events is sorted in time order, earliest first, latest last. The list is complete for the time period I am working on.
The idea being that I can change list:-
[[a],[b],[c],[d],[e],[f],[g],[h],[i]...]
where a, b, c, occur between mins 0 and 29, d,e,f,g occur between mins 30 and 59, nothing between 0 and 29 (next hour), h, i between 30 and 59 ...
into a new list:-
[[[a],[b],[c]],[[d],[e],[f],[g]],[],[[h],[i]]...]
I'm not sure how to build an iterator that loops through the two time slots until the time series list ends. Anything I can think of using xrange
stops once it completes, so I wondered if there was a way of using `while' to do the slicing?
I also will be using a smaller timeslot, probably 5 mins, I used 30mins as a shorter example for demonstration.
(for context, I'm making a geo plotted time based view of the recent quakes in New Zealand. and want to show all the quakes that occurs in a small block of time in one step to speed up the replay)