title: median-absolute-deviation (MAD) based outlier detection
body: <p>I wanted to apply median-absolute-deviation (MAD) based outlier detection using the answer from @Joe Kington as given below:</p>
  
  <p><a href="https://stackoverflow.com/questions/22354094/pythonic-way-of-detecting-outliers-in-one-dimensional-observation-data">Pythonic way of detecting outliers in one dimensional observation data</a></p>
  
  <p>However, what's going wrong with my code, I could not figure out how to assign the outliers as nan values for MY DATA:</p>
  
  <pre><code>import numpy as np
  data = np.array([55,32,4,5,6,7,8,9,11,0,2,1,3,4,5,6,7,8,25,25,25,25,10,11,12,25,26,27,28],dtype=float)
  median = np.median(data, axis=0)
  diff = np.sum((data - median)**2, axis=-1)
  diff = np.sqrt(diff)
  med_abs_deviation = np.median(diff)
  modified_z_score = 0.6745 * diff / med_abs_deviation
  data_without_outliers = data[modified_z_score &lt; 3.5]
  ?????
  print data_without_outliers
  </code></pre>