- I have an array that looks like this:
[1,2,4,1,2,5,1,2,6]
- Given a value of
3
- I want to find all value-pairs in the list above that encapsulate that given value.
i.e;
[2,4];[2,5];[2,6]
I can find the [2,6] values by using bisect, but how can I find all the values?
x = np.array([1,2,4,1,2,5])
xL = bisect_left(x,start)-1
xU = bisect_left(x,start)
print(xL ," ", xU)
lower = x[xL]
upper = x[xU]
print(lower, upper)
P.S. My actual data is quite large, so I do not think writing the code by myself with for loops etc. is a valid approach, so I want to mainly use build in libraries like pandas etc.