title: Index of First Value Where Condition Not Met Numpy
body: <p>I have a 2D numpy array that looks akin to this:</p>
  <pre><code>np.array([
    [5, 4, 3, 2, 1], 
    [4, 3, 3, 3, 3],
    [4, 4, 2, 5, 1],
    [2, 2, 2, 2, 1] 
  ])
  </code></pre>
  <p>I want to find the index of the first value that violates a condition, and if they all satisfy the condition, return the <code>maximum index + 1</code>. For example, I want to find the first index where the condition <code>value &gt;=3</code> is false.</p>
  <ul>
  <li><p>In <code>ls = [5,4,3,2,1]</code> it would be 3, as the
  first index where <code>value&gt;=3</code> is false is <code>ls[3]</code> which has the value
  <code>2</code>.</p>
  </li>
  <li><p>In <code>ls = [4,3,3,3,3]</code>, since all values in the list satisfy <code>value &gt;=3</code>, return the max index +1, which is 5.</p>
  </li>
  <li><p>For <code>ls= [4,4,2,5,1]</code> it would therefore be 2 since the first index
  that violates the condition is <code>ls[2]</code> which is the value <code>2</code>.</p>
  </li>
  <li><p>For <code>ls= [2,2,2,2,1]</code> it would therefore be 0 since the first index
  that violates the condition is <code>ls[0]</code> which is the value <code>2</code>.</p>
  </li>
  </ul>
  <p>My current attempt applies my condition to create a boolean mask, then uses <code>np.argmin()</code> to find the index of the first <code>false</code> value</p>
  <pre><code> np.apply_along_axis(
        lambda x: np.argmin(x&gt;=3),
        1,
        np.array([
            [5, 4, 3, 2, 1], 
            [4, 3, 3, 3, 3],
            [4, 4, 3, 5, 1],
            [2, 2, 2, 2, 1] 
        ])
    )
  </code></pre>
  <p>But this outputs <code>array([3, 0, 2, 0])</code> since this method cannot handle the second case when all values in the array satisfy the condition. Is there a better approach? Please keep in mind this has to be applied to over a few thousand of these arrays so ideally complexity must be kept to a minimum.</p>