title: Columnwise setting all values that meet a condition to zero
body: <p>I have an array that looks like this:</p>
  
  <pre><code>
      M=np.array([[1,2,3],[4,9,2],[3,5,6],[8,1,3]])
  
  </code></pre>
  
  <pre><code>&gt; M = [[1,2,3],
  &gt;      [4,9,2],
  &gt;      [3,5,6],
  &gt;      [8,1,3]]
  </code></pre>
  
  <p>For each column I want to set the two smallest values to zero.</p>
  
  <p>Thus I sort them in descending order (I know ascending would be faster)</p>
  
  <pre><code>
      M1 = np.sort(M, axis=0)[::-1]
  
  </code></pre>
  
  <p>Then I want to use something like</p>
  
  <pre><code>
      for column in range(M.shape[1]):
          for row in range(M.shape[0]):
              if M[row, column] &lt; M1[1,column]:        
                  M[row, column] = 0
  
  </code></pre>
  
  <p>and receive:</p>
  
  <pre><code>&gt; M = [[0,0,0],
  &gt;      [4,9,0],
  &gt;      [0,5,6],
  &gt;      [8,0,3]]
  </code></pre>
  
  <p>How can I make this last part more efficient (for array or DataFrame)?</p>