From c688580fe8d4bdb2d81b1a60dd9dfb06c459d41f Mon Sep 17 00:00:00 2001 From: junos Date: Mon, 3 Jul 2023 21:01:15 +0200 Subject: [PATCH] Increment answers separately if needed. --- exploration/expl_esm_labels.py | 10 +++++++++- features/esm_COPE.py | 5 ----- features/esm_SAM.py | 4 ---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/exploration/expl_esm_labels.py b/exploration/expl_esm_labels.py index 829bb10..3febdca 100644 --- a/exploration/expl_esm_labels.py +++ b/exploration/expl_esm_labels.py @@ -20,7 +20,13 @@ import datetime import seaborn as sns import participants.query_db -from features.esm import QUESTIONNAIRE_IDS, clean_up_esm, get_esm_data, preprocess_esm +from features.esm import ( + QUESTIONNAIRE_IDS, + clean_up_esm, + get_esm_data, + increment_answers, + preprocess_esm, +) from features.esm_COPE import reassign_question_ids from features.esm_JCQ import reverse_jcq_demand_control_scoring from features.esm_SAM import extract_stressful_events @@ -308,6 +314,7 @@ if export_data: "esm_user_answer_numeric", ] ] + df_esm_SAM_for_export = increment_answers(df_esm_SAM_for_export) df_esm_SAM_for_export.sort_values( by=["participant_id", "device_id", "_id"], ignore_index=True, inplace=True ) @@ -413,6 +420,7 @@ df_esm_COPE = df_esm_preprocessed[ # %% df_esm_COPE_clean = clean_up_esm(df_esm_COPE) +df_esm_COPE_clean = increment_answers(df_esm_COPE_clean) df_esm_COPE_fixed = reassign_question_ids(df_esm_COPE_clean) # %% diff --git a/features/esm_COPE.py b/features/esm_COPE.py index b48b155..5342f26 100644 --- a/features/esm_COPE.py +++ b/features/esm_COPE.py @@ -1,7 +1,5 @@ import pandas as pd -from features.esm import increment_answers - COPE_ORIGINAL_MAX = 4 COPE_ORIGINAL_MIN = 1 @@ -188,7 +186,4 @@ def reassign_question_ids(df_cope_cleaned: pd.DataFrame) -> pd.DataFrame: ) ) - # Finally, increment numeric answers. - df_cope_fixed = increment_answers(df_cope_fixed) - return df_cope_fixed diff --git a/features/esm_SAM.py b/features/esm_SAM.py index ac416b9..c8cc492 100644 --- a/features/esm_SAM.py +++ b/features/esm_SAM.py @@ -2,7 +2,6 @@ import numpy as np import pandas as pd import features.esm -from features.esm import increment_answers SAM_ORIGINAL_MAX = 5 SAM_ORIGINAL_MIN = 1 @@ -506,7 +505,4 @@ def reassign_question_ids(df_sam_cleaned: pd.DataFrame) -> pd.DataFrame: ) ) - # Finally, increment numeric answers. - df_sam_fixed = increment_answers(df_sam_fixed) - return df_sam_fixed