title: Most efficient way to find mode in numpy array
body: <p>I have a 2D array containing integers (both positive or negative). Each row represents the values over time for a particular spatial site, whereas each column represents values for various spatial sites for a given time.</p>
  
  <p>So if the array is like:</p>
  
  <pre><code>1 3 4 2 2 7
  5 2 2 1 4 1
  3 3 2 2 1 1
  </code></pre>
  
  <p>The result should be</p>
  
  <pre><code>1 3 2 2 2 1
  </code></pre>
  
  <p>Note that when there are multiple values for mode, any one (selected randomly) may be set as mode.</p>
  
  <p>I can iterate over the columns finding mode one at a time but I was hoping numpy might have some in-built function to do that. Or if there is a trick to find that efficiently without looping.</p>