I have a list, say:
list_A = [0,0,0,1.0,2.0,3.0,2.0,1.0,0,0,0]
I would like to find the minimum and maximum indices of this list, where list_A> 0.
i.e. in the example above it will be 3 and 7.
For other lists that grow monotonously, I used np.searchsorted , for example np.searchsorted(list,[0.5,1.0]) , to find indices in which the list is between 0.5 and 1.0 respectively.
But this case is completely different, and np.searchsorted doesn't work here, or maybe it does it the way I don't know!
source share