title: Iterating numpy array to find max value within subarray leaving the row index
body: <p>I wanted to find the max of 2D array along the axis=0 and I don't want to include the value at the row-index. I'm not happy with this solution because I need to run this on a million of rows and I don't want to use for-loop here. I tried <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.argmax.html" rel="nofollow noreferrer">numpy.argmax</a> but it calculates the max value of the row including the value at the row index.</p>
  
  <p><strong>My 2D Array</strong></p>
  
  <pre><code>Arry=([[1,   0.5, 0.3,   0,    0.2],
         [0,   1,   0.2,   0.8,  0],
         [0,   1,   1,     0.3,  0],
         [0,   0,   0,     1,    0]])
  </code></pre>
  
  <p><strong>Expected Output</strong></p>
  
  <pre><code>[1, 3, 1]
  </code></pre>
  
  <p>The first row [1,   0.5, 0.3,   0,    0.2] has max value at index 1 i.e. 0.5 since value 1 is at row index 0, Similarly in the second row max value is 0.8 i.e. index 3 and the 4th row doesn't have any max value since all are zero</p>
  
  <p><strong>My Code</strong></p>
  
  <pre><code>import numpy as np
  
  for idx,subarry in enumerate(Arry):
      newlist=np.delete(subarry, idx)
      idx_min=min(np.where(subarry==np.max(newlist))[0])
      if idx_min != 0: min_elem_idx.append(idx_min)
  
  print(min_elem_idx)
  [1, 3, 1]
  </code></pre>
  
  <p>I am looking for a Pythonic way to achieve this without using the for loop</p>