You can work from the same principles as the "first time" case, just with a slightly more complicated middle step.
Start with the boolean array representing your condition:
cond = aa > 0
Convert the True/False values in the array to counts:
counts = np.cumsum(cond)
Search for the first occurrence of the count you're looking for:
idx = np.searchsorted(counts, 10)
Remember that the 10
in this last line refers to the tenth value that satisfies the condition, and the first value has count 1
.
Alternately, you could convert the condition array to indices:
indices, = np.nonzero(cond)
idx = indices[9]
Note that in this setup, the tenth value will be at index 9
.