title: Replacing Numpy elements if condition is met
body: <p>I have a large numpy array that I need to manipulate so that each element is changed to either a 1 or 0 if a condition is met (will be used as a pixel mask later). There are about 8 million elements in the array and my current method takes too long for the reduction pipeline:</p>
  
  <pre><code>for (y,x), value in numpy.ndenumerate(mask_data): 
  
      if mask_data[y,x]&lt;3: #Good Pixel
          mask_data[y,x]=1
      elif mask_data[y,x]&gt;3: #Bad Pixel
          mask_data[y,x]=0
  </code></pre>
  
  <p>Is there a numpy function that would speed this up?</p>