0

I have an array defined below

y = [0,0,0,0,0,1,1,1,1,2,2,3,4,5,6,7,7,7,199,199,199]

I would like to iterate through and pick out the index of the elements that are either greater than 7, or less than 1. I was initially using the

np.where((y<0) & (y>7))

But that doesn't make sense at all. I haven't been able to figure out how to change the 'and' operator into a 'or'.

martineau
  • 119,623
  • 25
  • 170
  • 301
may7even
  • 121
  • 2
  • 8

1 Answers1

3
[i for i, e in enumerate(y) if e > 7 or e < 1]
Samwise
  • 68,105
  • 3
  • 30
  • 44