aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/presentation/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'resources/tools/presentation/utils.py')
-rw-r--r--resources/tools/presentation/utils.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/resources/tools/presentation/utils.py b/resources/tools/presentation/utils.py
index 2fbf70cadc..a15742a21f 100644
--- a/resources/tools/presentation/utils.py
+++ b/resources/tools/presentation/utils.py
@@ -81,15 +81,26 @@ def remove_outliers(input_list, outlier_const=1.5, window=14):
:rtype: list of floats
"""
- input_series = pd.Series()
- for index, value in enumerate(input_list):
- item_pd = pd.Series([value, ], index=[index, ])
- input_series.append(item_pd)
- output_series, _ = split_outliers(input_series, outlier_const=outlier_const,
- window=window)
- output_list = [y for x, y in output_series.items() if not np.isnan(y)]
-
- return output_list
+ data = np.array(input_list)
+ upper_quartile = np.percentile(data, 75)
+ lower_quartile = np.percentile(data, 25)
+ iqr = (upper_quartile - lower_quartile) * outlier_const
+ quartile_set = (lower_quartile - iqr, upper_quartile + iqr)
+ result_lst = list()
+ for y in data.tolist():
+ if quartile_set[0] <= y <= quartile_set[1]:
+ result_lst.append(y)
+ return result_lst
+
+ # input_series = pd.Series()
+ # for index, value in enumerate(input_list):
+ # item_pd = pd.Series([value, ], index=[index, ])
+ # input_series.append(item_pd)
+ # output_series, _ = split_outliers(input_series, outlier_const=outlier_const,
+ # window=window)
+ # output_list = [y for x, y in output_series.items() if not np.isnan(y)]
+ #
+ # return output_list
def split_outliers(input_series, outlier_const=1.5, window=14):