aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/presentation/utils.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2018-04-23 16:57:44 +0200
committerTibor Frank <tifrank@cisco.com>2018-04-23 16:57:44 +0200
commit52f64f232293130904d54a62609eaffc1b145608 (patch)
tree60bb6664cc3337eabd240180fa470c6afae3df4a /resources/tools/presentation/utils.py
parent6f8266f81bb052e2c0e51b029e47f0eb4f04a7ed (diff)
CSIT-1041: Trending dashboard
Change-Id: I8d53c68643acb18bf2b5ab171672b0de02d2d135 Signed-off-by: Tibor Frank <tifrank@cisco.com>
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):