Fix the accelerometer bug: without evening data

pull/95/head
Meng Li 2020-06-25 18:43:24 -04:00
parent 6608e47918
commit e66ed6a79b
1 changed files with 3 additions and 1 deletions

View File

@ -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)