title: Deleting rows in np array inside a for loop
body: <p>I am trying to delete all rows in which there is one or less non-zero elements, in multiple 2D arrays contained within the list 'a'.</p>
  
  <p>This method works when I run it outside the 'i' loop, but does not as a whole. I know that I cannot delete rows over which I am iterating, but I believe that I am not doing so in this case, because I am only deleting rows in arrays contained in a, not the arrays themselves.  </p>
  
  <pre><code>for i in range(len(a)):
    del_idx=[]
    for j in range(len(a[i])):
      nonzero=np.nonzero(a[i][j])
      nonzero_len=len(nonzero[0]) #because np.nonzero outputs a tuple
      if nonzero_len&lt;=1:
          del_idx.append(j)
      else:
          continue
    np.delete(a[i],(del_idx),axis=0)
  </code></pre>
  
  <p>Anyone know what's going on here? If this really does not work, how can I delete these elements without using a loop? This is Python 2.7</p>
  
  <p>Thank you!</p>