Export COPE data.

master
junos 2023-07-03 18:33:28 +02:00
parent 5c0e2e2621
commit e3be17e56e
1 changed files with 32 additions and 2 deletions

View File

@ -307,11 +307,11 @@ if export_data:
] ]
] ]
df_esm_SAM_for_export.sort_values( 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()) print(df_esm_SAM_for_export.head())
df_esm_SAM_for_export.to_csv( 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] # %% [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_active"])
& (df_esm_preprocessed["questionnaire_id"] <= QUESTIONNAIRE_IDS["COPE_emotions"]) & (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)