Skip to content

Commit 7f1c502

Browse files
ChinW97JulioV
authored andcommitted
Fixed bug: Added local_segment column if no data left after filtered
1 parent 2e3e433 commit 7f1c502

File tree

1 file changed

+3
-2
lines changed
  • src/features/phone_accelerometer/panda

1 file changed

+3
-2
lines changed

src/features/phone_accelerometer/panda/main.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ def panda_features(sensor_data_files, time_segment, provider, filter_data_by_seg
6060
if not acc_data.empty:
6161
acc_data = filter_data_by_segment(acc_data, time_segment)
6262

63+
6364
if not acc_data.empty:
64-
acc_features = pd.DataFrame()
6565
# drop rows where we only have one row per minute (no variance)
6666
acc_data = dropRowsWithCertainThreshold(acc_data, 1)
6767

6868
if not acc_data.empty:
69+
acc_features = pd.DataFrame()
6970
# check if the participant performs exertional activity for each minute
7071
acc_minute = pd.DataFrame()
7172
acc_minute["isexertionalactivity"] = (acc_data.groupby(["local_timezone", "local_segment", "local_date", "local_hour", "local_minute"])["double_values_0"].var() + acc_data.groupby(["local_timezone", "local_segment", "local_date", "local_hour", "local_minute"])["double_values_1"].var() + acc_data.groupby(["local_timezone", "local_segment", "local_date", "local_hour", "local_minute"])["double_values_2"].var()).apply(lambda x: 1 if x > 0.15 * (9.807 ** 2) else 0)
@@ -83,7 +84,7 @@ def panda_features(sensor_data_files, time_segment, provider, filter_data_by_seg
8384
acc_features = statsFeatures(nonexertionalactivity_episodes, features_to_compute_nonexertionalactivityepisode, "durationnonexertionalactivityepisode", acc_features)
8485

8586
acc_features[[colname for colname in acc_features.columns if "std" not in colname]] = acc_features[[colname for colname in acc_features.columns if "std" not in colname]].fillna(0)
86-
87+
8788
acc_features = acc_features.reset_index()
8889

8990
return acc_features

0 commit comments

Comments
 (0)