From 3c54b87a626ac2f54ed52b8d17a7f3179020576a Mon Sep 17 00:00:00 2001 From: Joanne S Date: Mon, 12 Nov 2018 10:50:34 -0800 Subject: [PATCH 1/2] changed time to timeField --- tidepool-analysis-tools/tidals/clean/clean.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tidepool-analysis-tools/tidals/clean/clean.py b/tidepool-analysis-tools/tidals/clean/clean.py index 9a4f1836..477dc54a 100644 --- a/tidepool-analysis-tools/tidals/clean/clean.py +++ b/tidepool-analysis-tools/tidals/clean/clean.py @@ -31,8 +31,8 @@ def round_time(df, timeIntervalMinutes=5, timeField="time", df.reset_index(drop=True, inplace=True) # calculate the time-in-between (TIB) consecutive records - t = pd.to_datetime(df.time) - t_shift = pd.to_datetime(df.time.shift(1)) + t = pd.to_datetime(df.timeField) + t_shift = pd.to_datetime(df.timeField.shift(1)) df["TIB"] = round((t - t_shift).dt.days*(86400/(60 * timeIntervalMinutes)) + (t - t_shift).dt.seconds/(60 * timeIntervalMinutes)) * timeIntervalMinutes From 2022cb949a35e4483a23ca28f7f8dda0f430ace1 Mon Sep 17 00:00:00 2001 From: Joanne S Date: Mon, 12 Nov 2018 11:09:20 -0800 Subject: [PATCH 2/2] dot to bracket reference Dot referencing the column caused an error. --- tidepool-analysis-tools/tidals/clean/clean.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tidepool-analysis-tools/tidals/clean/clean.py b/tidepool-analysis-tools/tidals/clean/clean.py index 477dc54a..b6028570 100644 --- a/tidepool-analysis-tools/tidals/clean/clean.py +++ b/tidepool-analysis-tools/tidals/clean/clean.py @@ -31,8 +31,8 @@ def round_time(df, timeIntervalMinutes=5, timeField="time", df.reset_index(drop=True, inplace=True) # calculate the time-in-between (TIB) consecutive records - t = pd.to_datetime(df.timeField) - t_shift = pd.to_datetime(df.timeField.shift(1)) + t = pd.to_datetime(df[timeField]) + t_shift = pd.to_datetime(df[timeField].shift(1)) df["TIB"] = round((t - t_shift).dt.days*(86400/(60 * timeIntervalMinutes)) + (t - t_shift).dt.seconds/(60 * timeIntervalMinutes)) * timeIntervalMinutes