title: Numpy array: how to row-wise check if first X amount of values are valid?
body: <h2>Problem Description</h2>
  
  <p>Consider the following two example arrays:</p>
  
  <pre><code>arr = np.array([
      [5.0, 2.0, 1.0, np.nan, np.nan],
      [9.0, np.nan, np.nan, np.nan, 2.0],
      [4.0, 7.0, 4.0, np.nan, np.nan],
      [8.0, np.nan, np.nan, np.nan, np.nan],
      [np.nan, np.nan, np.nan, np.nan, np.nan],
      [np.nan, np.nan, np.nan, np.nan, 6.0]
  ])
  
  amounts = np.array([
      3,
      1,
      2,
      3,
      0,
      5
  ])
  </code></pre>
  
  <p>For each row in array <code>arr</code> I would like to check if the first X entries in the row are not <code>NaN</code>, but all the other entries are <code>NaN</code>. This amount X is different for each row and is given by array <code>amounts</code>.</p>
  
  <p>So my expected result would be the following boolean array:</p>
  
  <pre><code>array([ True, False, False, False,  True, False])
  </code></pre>
  
  <h2>Tried thus far</h2>
  
  <p>I managed to come up with the following working code:</p>
  
  <pre><code>result = []
  for (row, amount) in zip(arr, amounts):
      if (~np.isnan(row)[:amount]).all() and np.isnan(row)[amount:].all():
          result.append(True)
      else:
          result.append(False)
  
  result = np.array(result)
  print(result)
  </code></pre>
  
  <p>Though this code produces the desired result, I have the feeling that it's still inefficient. I would suspect that a method without any for-loops is possible, but I haven't been able to find it yet.</p>
  
  <p>Would anyone be able to help find a fully vectorized solution for this problem?</p>