From 3a7d234619b97bf0bb3d821d04eddf294ae712ed Mon Sep 17 00:00:00 2001 From: rozetko Date: Fri, 8 Jun 2018 21:14:06 +0300 Subject: [PATCH] Fix error with second learning --- analytics/data_provider.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/analytics/data_provider.py b/analytics/data_provider.py index bc47465..78f83c6 100644 --- a/analytics/data_provider.py +++ b/analytics/data_provider.py @@ -52,17 +52,20 @@ class DataProvider: return result dataframe = self.get_dataframe(None) for anomaly in anomalies: - start_time = pd.to_datetime(anomaly['start']-1, unit='ms') - finish_time = pd.to_datetime(anomaly['finish']+1, unit='ms') - current_index = (dataframe['timestamp'] >= start_time) & (dataframe['timestamp'] <= finish_time) + start_time = pd.to_datetime(anomaly['start'] + 1, unit='ms') + finish_time = pd.to_datetime(anomaly['finish'] - 1, unit='ms') + current_index = (dataframe['timestamp'] >= start_time) & ( + dataframe['timestamp'] <= finish_time) anomaly_frame = dataframe[current_index] + if anomaly_frame.empty: + continue + cur_anomaly = { 'start': anomaly_frame.index[0], 'finish': anomaly_frame.index[len(anomaly_frame) - 1], 'labeled': anomaly['labeled'] } result.append(cur_anomaly) - return result def inverse_transform_indexes(self, indexes):