title: How do I select elements of an array given condition?
body: <p>Suppose I have a numpy array <code>x = [5, 2, 3, 1, 4, 5]</code>, <code>y = ['f', 'o', 'o', 'b', 'a', 'r']</code>. I want to select the elements in <code>y</code> corresponding to elements in <code>x</code> that are greater than 1 and less than 5.</p>
  
  <p>I tried</p>
  
  <pre><code>x = array([5, 2, 3, 1, 4, 5])
  y = array(['f','o','o','b','a','r'])
  output = y[x &gt; 1 &amp; x &lt; 5] # desired output is ['o','o','a']
  </code></pre>
  
  <p>but this doesn't work. How would I do this?</p>