title: Find index of first element with condition in numpy array in python
body: <p>I'm trying find the index of the first element bigger than a threshold, like this:</p>
  
  <pre><code>index = 0
  while timeStamps[index] &lt; self.stopCount and index &lt; len(timeStamps):
      index += 1
  </code></pre>
  
  <p>Can this be done in a one-liner? I found:</p>
  
  <pre><code>index = next((x for x in timeStamps if x &lt;= self.stopCount), 0)
  </code></pre>
  
  <p>I'm not sure what this expression does and it seems to return 0 always... Could somebody point out the error and explain the expression?</p>