Alan Gauld wrote: > > > I assume there is a good reason to use a numpy array instead of > a regular list? ie You need a numpy array elsewhere in the code? > I've never used numpy bt there is a possibility that array access > is slower than list access, but I have no idea. It just adds an extra > level of complexity thats all. >
Yes, I use numpy a lot, my understanding is that is is quite a bit faster than lists... but perhaps not in a case like this. >> As for your comment regarding the invariant... would it be: >> while hr q: >> > > I think he meant > > while hr <= q > > as per your original code > Okay, thanks! > >>>> ind = np.where( (X[:,0] > hr) & (X[:,0] < nhr) ) > > I have no idea what this is doing but do you really mean a bitwise > and here? You are effectively bitwise anding two boolean values > which seems odd to put it mildly... > Well, effectively I am searching the array for values matching the criteria, but maybe I don't understand the bitwise details. What I am trying to say is: " index = X where hr < X[:,0] < nhr " I had problems though when I tried to code it as such: ind = np.where((hr < X[:,0] < nhr)) this doesn't work, though you think it would... > HTH, > -- > Alan Gauld > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > Yes, thank you. -- View this message in context: http://www.nabble.com/using-datetime-and-calculating-hourly-average-tp24370537p24377741.html Sent from the Python - tutor mailing list archive at Nabble.com. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor