def remove_outliers(idx_ts):
"""Remove outliers from a given timestamps array.
Parameters
----------
idx_ts : numpy.ndarray
given timestamp array.
Returns
-------
idx_ts_new : numpy.ndarray.
outliers removed timestamp array.
"""
idx_ts_new = idx_ts.copy()
summary = np.percentile(idx_ts_new, [25, 50, 75])
high_lim = summary[0] - 1.5 * (summary[2] - summary[1])
low_lim = summary[2] + 1.5 * (summary[2] - summary[1])
idx_ts_new = idx_ts_new[~(idx_ts_new >= low_lim)]
idx_ts_new = idx_ts_new[~(idx_ts_new <= high_lim)]
return idx_ts_new
评论列表
文章目录