Reputation: 4640
Say I have 3 vectors:
v1 = 1,6,7
v2 = 2,5,6
v3 = 3,4,2
I want to count how many times that v1[i] <= v2[i] <= v3[i]
(in a Pythonic way of course). For the above example, the answer should be 1
.
Upvotes: 0
Views: 68
Reputation: 643
If the v1
, v2
, and so on arenumpy.arrays
you can do
np.sum(np.logical_and(v1<v2, v2<v3))
Upvotes: 0