title: Calculate mode of given axis of masked numpy array
body: <p>I want to calculate the mode of columns in a numpy array, excluding a specific value (0) from the calculation. </p>
  
  <p>Example numpy array:</p>
  
  <pre><code>n=np.array([[0,2,1], [0,1,3], [1,2,3]])
  &gt;array([[0, 2, 1],
     [0, 1, 3],
     [1, 2, 3]])
  </code></pre>
  
  <p>create mask for where values dont equal 0</p>
  
  <pre><code>m_mask = n != 0    
  &gt;array([[False,  True,  True],
     [False,  True,  True],
     [ True,  True,  True]])
  </code></pre>
  
  <p>Apply the mask and calculate mean on axis 0:</p>
  
  <pre><code>from scipy.stats import mode
  
  new_m = np.ma.array(n, mask = m_mask)
  m=mode(new_m, axis=0)
  m[0]  #access the values not the count
  &gt;array([[0, 2, 3]])
  </code></pre>
  
  <p>Seems like scipy.stats.mean may be ignoring the masked array?</p>
  
  <p>Any ideas on how I can accomplish this?</p>