Document extract_stressful_events.

master
junos 2023-07-03 17:37:34 +02:00
parent dbb2033f78
commit 471ce7c2cb
1 changed files with 19 additions and 0 deletions

View File

@ -25,6 +25,25 @@ GROUP_QUESTIONNAIRES_BY = [
def extract_stressful_events(df_esm: pd.DataFrame) -> pd.DataFrame: 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. # 0. Select only questions from Stress Appraisal Measure.
df_esm_preprocessed = features.esm.preprocess_esm(df_esm) df_esm_preprocessed = features.esm.preprocess_esm(df_esm)
df_esm_sam = df_esm_preprocessed[ df_esm_sam = df_esm_preprocessed[