From e66ed6a79be4b97a784e604bf2c397a18baa0e00 Mon Sep 17 00:00:00 2001 From: Meng Li <34143965+Meng6@users.noreply.github.com> Date: Thu, 25 Jun 2020 18:43:24 -0400 Subject: [PATCH] Fix the accelerometer bug: without evening data --- src/features/accelerometer/accelerometer_base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/features/accelerometer/accelerometer_base.py b/src/features/accelerometer/accelerometer_base.py index bc830505..fcd2691f 100644 --- a/src/features/accelerometer/accelerometer_base.py +++ b/src/features/accelerometer/accelerometer_base.py @@ -75,7 +75,9 @@ def base_accelerometer_features(acc_data, day_segment, requested_features, valid else: if day_segment != "daily": acc_data = acc_data[acc_data["local_day_segment"] == day_segment] - if not acc_data.empty: + if acc_data.empty: + acc_features = pd.DataFrame(columns=["local_date"] + ["acc_" + day_segment + "_" + x for x in features_to_compute]) + else: acc_features = pd.DataFrame() # get magnitude related features: magnitude = sqrt(x^2+y^2+z^2) magnitude = acc_data.apply(lambda row: np.sqrt(row["double_values_0"] ** 2 + row["double_values_1"] ** 2 + row["double_values_2"] ** 2), axis=1)