"John [H2O]" <washa...@gmail.com> wrote

        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 "

In Python you can do that comparison directly:

ind = np.where( hr < X[:,0] < nhr)

What you were doping was evaluating the comparisons as boolean
expressions then doing a bitwise and of the results, you should have
used a logical and:

ind = np.where( (X[:,0] > hr) and  (X[:,0] < nhr) )

Which would do what you want, but the direct approach is prettier IMHO.

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...

Yes I wpuld... You shouldn't need the inner parens but they
shouldn't stop it working either. What does happen?
Do you get an error message? What is the argument
to np.where()?

And of course it could all be irrelevant since as Sander pointed
out you can compare datetime objects directly...

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to