From d4d74818e69eab2755f988391978400096902b5d Mon Sep 17 00:00:00 2001 From: Primoz Date: Wed, 26 Oct 2022 14:14:32 +0000 Subject: [PATCH] Fix a bug - missing time_segment column when df is empty --- src/features/phone_esm/straw/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/features/phone_esm/straw/main.py b/src/features/phone_esm/straw/main.py index 306bb681..4f5b060b 100644 --- a/src/features/phone_esm/straw/main.py +++ b/src/features/phone_esm/straw/main.py @@ -52,7 +52,6 @@ def straw_features(sensor_data_files, time_segment, provider, filter_data_by_seg if not esm_data.empty: esm_features = pd.DataFrame() - for scale in requested_scales: questionnaire_id = QUESTIONNAIRE_IDS[scale] mask = esm_data["questionnaire_id"] == questionnaire_id @@ -60,4 +59,7 @@ def straw_features(sensor_data_files, time_segment, provider, filter_data_by_seg #TODO Create the column esm_user_score in esm_clean. Currently, this is only done when reversing. esm_features = esm_features.reset_index() + if 'index' in esm_features: # In calse of empty esm_features df + esm_features.rename(columns={'index': 'local_segment'}, inplace=True) + return esm_features