The IQR rule flags values far outside the middle 50% of the data. Unlike z-scores, it isn't thrown off by the outliers themselves.
Implement iqr_outliers(values, k=1.5) returning (lower, upper, outlier_indices):
np.percentile (its default linear interpolation).outlier_indices is a sorted list of the positions of values strictly outside [lower, upper].NaN values when computing the quartiles, and never flag them.