From 9f1b2397d0193df286fa1466852d68883f77396b Mon Sep 17 00:00:00 2001 From: rozetko Date: Fri, 31 Aug 2018 20:09:29 +0300 Subject: [PATCH] Convert timestamps from s to ms --- analytics/analytic_unit_manager.py | 2 +- analytics/models/drop_model.py | 4 ++-- analytics/models/general_model.py | 4 ++-- analytics/models/jump_model.py | 4 ++-- analytics/models/peak_model.py | 4 ++-- analytics/models/trough_model.py | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analytics/analytic_unit_manager.py b/analytics/analytic_unit_manager.py index a4cdf87..e8f8d8b 100644 --- a/analytics/analytic_unit_manager.py +++ b/analytics/analytic_unit_manager.py @@ -60,7 +60,7 @@ def prepare_data(data: list): """ data = pd.DataFrame(data, columns=['timestamp', 'value']) - data['timestamp'] = pd.to_datetime(data['timestamp']) + data['timestamp'] = pd.to_datetime(data['timestamp'], unit='ms') data['value'] = data['value'] - min(data['value']) return data diff --git a/analytics/models/drop_model.py b/analytics/models/drop_model.py index ae214f3..15cb130 100644 --- a/analytics/models/drop_model.py +++ b/analytics/models/drop_model.py @@ -36,8 +36,8 @@ class DropModel(Model): drop_length_list = [] for segment in segments: if segment['labeled']: - segment_from_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['from'])) - segment_to_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['to'])) + segment_from_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['from'], unit='ms')) + segment_to_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['to'], unit='ms')) segment_data = data[segment_from_index: segment_to_index + 1] if len(segment_data) == 0: diff --git a/analytics/models/general_model.py b/analytics/models/general_model.py index 80a78ba..33b5bf4 100644 --- a/analytics/models/general_model.py +++ b/analytics/models/general_model.py @@ -35,8 +35,8 @@ class GeneralModel(Model): convolve_list = [] for segment in segments: if segment['labeled']: - segment_from_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['from'])) - segment_to_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['to'])) + segment_from_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['from'], unit='ms')) + segment_to_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['to'], unit='ms')) segment_data = data[segment_from_index: segment_to_index + 1] if len(segment_data) == 0: diff --git a/analytics/models/jump_model.py b/analytics/models/jump_model.py index 64ac66d..67a9929 100644 --- a/analytics/models/jump_model.py +++ b/analytics/models/jump_model.py @@ -39,8 +39,8 @@ class JumpModel(Model): jump_length_list = [] for segment in segments: if segment['labeled']: - segment_from_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['from'])) - segment_to_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['to'])) + segment_from_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['from'], unit='ms')) + segment_to_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['to'], unit='ms')) segment_data = data[segment_from_index: segment_to_index + 1] if len(segment_data) == 0: diff --git a/analytics/models/peak_model.py b/analytics/models/peak_model.py index 06195d5..5b29cb7 100644 --- a/analytics/models/peak_model.py +++ b/analytics/models/peak_model.py @@ -34,8 +34,8 @@ class PeakModel(Model): convolve_list = [] for segment in segments: if segment['labeled']: - segment_from_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['from'])) - segment_to_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['to'])) + segment_from_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['from'], unit='ms')) + segment_to_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['to'], unit='ms')) segment_data = data[segment_from_index: segment_to_index + 1] if len(segment_data) == 0: diff --git a/analytics/models/trough_model.py b/analytics/models/trough_model.py index 8018acc..06ae826 100644 --- a/analytics/models/trough_model.py +++ b/analytics/models/trough_model.py @@ -33,8 +33,8 @@ class TroughModel(Model): convolve_list = [] for segment in segments: if segment['labeled']: - segment_from_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['from'])) - segment_to_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['to'])) + segment_from_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['from'], unit='ms')) + segment_to_index = utils.timestamp_to_index(dataframe, pd.to_datetime(segment['to'], unit='ms')) segment_data = data[segment_from_index: segment_to_index + 1] if len(segment_data) == 0: