code: def std_filter(array, n_std=2.0, return_index=False):
      
      if not isinstance(array, np.ndarray):
          array = np.array(array)
      mean, std = array.mean(), array.std()
  
      good_index = np.where(abs(array - mean) <= n_std * std)
      bad_index = np.where(abs(array - mean) > n_std * std)
  
      if return_index:
          return good_index[0], bad_index[0]
      else:
          return array[good_index], array[bad_index]
docs: Standard deviation outlier detector.
  
      :param array: array of data.
      :param n_std: default 2.0, exclude data out of ``n_std`` standard deviation.
      :param return_index: boolean, default False, if True, only returns index.