title: Python replacing max values in array
body: <p>I have a 3D numpy array <code>A</code> of shape 10 x 5 x 3. I also have a vector <code>B</code> of length 3 (length of last axis of <code>A</code>). I want to compare each <code>A[:,:,i]</code> against <code>B[i]</code> where <code>i = 0:2</code> and replace all values <code>A[:,:,i] &gt; B[i]</code> with <code>B[i]</code>.</p>
  
  <p>Is there a way to achieve this without a for loop.</p>
  
  <p>Edit: I tried the <code>argmax</code> across <code>i = 0:2</code> using a for loop
  <a href="https://stackoverflow.com/questions/10984750/python-replace-values-in-2d-numpy-array">python replace values in 2d numpy array</a></p>