I have a 2D array in the following form:
[[X1, X2, ..., XN]
[Y1, Y2, ..., YN]]
For each Xi
greater than lower_limit_X
and less than upper_limit_X
, I would like to get the number of Yi
's that are greater than lower_limit_Y
and less than upper_limit_Y
.
I hope there is an efficient way of doing this in Numpy apart from indexing one by one.
EDIT: So I have a 2xN array. The first row has ordered values of N X's and second row has ordered values of N Y's. What I would like to get is:
get a the
lowest_index
andhighest_index
index of X, that have a value that is greater thanlower_limit_X
and less thanupper_limit_X
then slice the Y array (just one array) in the index range [
lowest_index
,highest_index
]count the number of elements in my slice, having Yi
's that are greater than
lower_limit_Yand less than
upper_limit_Y`.
Y
, or do you mean "for each unique value of Xi"? – NPE Dec 6 '12 at 10:43