I have a numpy
array of np.shape
=(n,)
I am attempting to iterate through each value of the array and subtract the 2nd value from the 1st, then see if the difference is greater than 1.
So, array[1]-array[0] > 1 ?
, then array[2]-array[1] > 1 ?
.
I read that this is simple with np.diff()
, which returns for me another array of boolean True/False values:
np.diff(array) > 1
gives [False False True False True]
, for example.
- How can I get the exact values of each
False
orTrue
item in a separate array? - How can I get the location of each
False
orTrue
within the array?
I tried array[array>1]
and variations of this but nothing has worked thus far.
EDIT: I used AJH's answer below, which worked for me.