From 471ce7c2cbb410835188da483afc64e65719703b Mon Sep 17 00:00:00 2001 From: junos Date: Mon, 3 Jul 2023 17:37:34 +0200 Subject: [PATCH] Document extract_stressful_events. --- features/esm_SAM.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/features/esm_SAM.py b/features/esm_SAM.py index 302c172..4d75560 100644 --- a/features/esm_SAM.py +++ b/features/esm_SAM.py @@ -25,6 +25,25 @@ GROUP_QUESTIONNAIRES_BY = [ def extract_stressful_events(df_esm: pd.DataFrame) -> pd.DataFrame: + """ + Extract information about stressful events. + + Participants were asked: "Was there a particular event that created tension in you?" + Then a subset of questions related to this event followed. + This function goes through the follow-up questions one by one + and preprocesses them, so that it adds new columns to the dataframe. + + Parameters + ---------- + df_esm: pd.DataFrame + A raw dataframe of all ESM data. + + Returns + ------- + df_esm_events: pd.DataFrame + A cleaned up df of Stress Appraisal Measure items with additional columns. + + """ # 0. Select only questions from Stress Appraisal Measure. df_esm_preprocessed = features.esm.preprocess_esm(df_esm) df_esm_sam = df_esm_preprocessed[