From e3be17e56e9b878588434012935623d93fb8c748 Mon Sep 17 00:00:00 2001 From: junos Date: Mon, 3 Jul 2023 18:33:28 +0200 Subject: [PATCH] Export COPE data. --- exploration/expl_esm_labels.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/exploration/expl_esm_labels.py b/exploration/expl_esm_labels.py index 086678d..6807195 100644 --- a/exploration/expl_esm_labels.py +++ b/exploration/expl_esm_labels.py @@ -307,11 +307,11 @@ if export_data: ] ] df_esm_SAM_for_export.sort_values( - by=["participant_id", "datetime_lj", "_id"], ignore_index=True, inplace=True + by=["participant_id", "device_id", "_id"], ignore_index=True, inplace=True ) print(df_esm_SAM_for_export.head()) df_esm_SAM_for_export.to_csv( - "../data/raw/df_esm_SAM_daily_threat_challenge.csv", index=False + "../data/raw/df_esm_SAM_threat_challenge.csv", index=False ) # %% [markdown] @@ -408,3 +408,33 @@ df_esm_COPE = df_esm_preprocessed[ (df_esm_preprocessed["questionnaire_id"] >= QUESTIONNAIRE_IDS["COPE_active"]) & (df_esm_preprocessed["questionnaire_id"] <= QUESTIONNAIRE_IDS["COPE_emotions"]) ] + +# %% +df_esm_COPE_clean = clean_up_esm(df_esm_COPE) + +# %% +if export_data: + df_esm_COPE_for_export = df_esm_COPE_clean[ + [ + "participant_id", + "username", + "device_id", + "_id", + "esm_trigger", + "esm_session", + "esm_notification_id", + "question_id", + "questionnaire_id", + "double_esm_user_answer_timestamp", + "datetime_lj", + "date_lj", + "time", + "esm_user_answer", + "esm_user_answer_numeric", + ] + ] + df_esm_COPE_for_export.sort_values( + by=["participant_id", "device_id", "_id"], ignore_index=True, inplace=True + ) + print(df_esm_COPE_for_export.head()) + df_esm_COPE_for_export.to_csv("../data/raw/df_esm_COPE.csv", index=False)