title: Comparing values in two numpy arrays with 'if'
body: <p>Im fairly new to numpy arrays and have encountered a problem when comparing one array with another.</p>
  
  <p>I have two arrays, such that:</p>
  
  <pre><code>a = np.array([1,2,3,4,5])
  b = np.array([2,4,3,5,2])
  </code></pre>
  
  <p>I want to do something like the following:</p>
  
  <pre><code>if b &gt; a:
      c = b
  else:
      c = a
  </code></pre>
  
  <p>so that I end up with an array c = np.array([2,4,3,5,5]).</p>
  
  <p>This can be otherwise thought of as taking the max value for each element of the two arrays.</p>
  
  <p>However, I am running into the error </p>
  
  <pre><code>ValueError: The truth value of an array with more than one element is ambiguous. 
  Use a.any() or a.all(). 
  </code></pre>
  
  <p>I have tried using these but Im not sure that the are right for what I want.</p>
  
  <p>Is someone able to offer some advice in solving this?</p>