title: Conditionals on one numpy array while iterating over a second numpy array
body: <p>I read through the numpy documentation, especially as it pertains to iterating over ndarrays in a for loop. Read through suggested similar S.O. posts, but I'm still failing to solve what seems to be a relatively straight-forward problem.</p>
  
  <p>I'd like to incorporate conditionals based on values of one ndarray while iterating over a different ndarray, element-wise.  Here's my code:</p>
  
  <pre><code>import numpy as np
  array1 = np.array([10,20,30,40,50])
  array2 = np.array([-1,-1,1,0,1])
  for x in np.nditer(array1,flags=['refs_ok']):
      if array2[x] &lt; 0:
         #code-block here executing several tasks
  </code></pre>
  
  <p>I get the following error in reference to the if statement: "IndexError: index 10 is out of bounds for axis 0 with size 5".       </p>
  
  <p>The code block must be executed in a time-series manner, thus the for-loop. Not sure what's going on.</p>