Increment answers separately if needed.

master
junos 2023-07-03 21:01:15 +02:00
parent 8c0b66eddc
commit c688580fe8
3 changed files with 9 additions and 10 deletions

View File

@ -20,7 +20,13 @@ import datetime
import seaborn as sns import seaborn as sns
import participants.query_db 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_COPE import reassign_question_ids
from features.esm_JCQ import reverse_jcq_demand_control_scoring from features.esm_JCQ import reverse_jcq_demand_control_scoring
from features.esm_SAM import extract_stressful_events from features.esm_SAM import extract_stressful_events
@ -308,6 +314,7 @@ if export_data:
"esm_user_answer_numeric", "esm_user_answer_numeric",
] ]
] ]
df_esm_SAM_for_export = increment_answers(df_esm_SAM_for_export)
df_esm_SAM_for_export.sort_values( df_esm_SAM_for_export.sort_values(
by=["participant_id", "device_id", "_id"], ignore_index=True, inplace=True 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 = 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) df_esm_COPE_fixed = reassign_question_ids(df_esm_COPE_clean)
# %% # %%

View File

@ -1,7 +1,5 @@
import pandas as pd import pandas as pd
from features.esm import increment_answers
COPE_ORIGINAL_MAX = 4 COPE_ORIGINAL_MAX = 4
COPE_ORIGINAL_MIN = 1 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 return df_cope_fixed

View File

@ -2,7 +2,6 @@ import numpy as np
import pandas as pd import pandas as pd
import features.esm import features.esm
from features.esm import increment_answers
SAM_ORIGINAL_MAX = 5 SAM_ORIGINAL_MAX = 5
SAM_ORIGINAL_MIN = 1 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 return df_sam_fixed