rapids/src/features/phone_esm/straw/preprocess.py

17 lines
580 B
Python

from esm_preprocess import *
questionnaire_name = snakemake.params["questionnaire_name"]
df_esm = pd.read_csv(snakemake.input[0])
df_esm_preprocessed = preprocess_esm(df_esm)
try:
questionnaire_id = QUESTIONNAIRE_IDS[questionnaire_name]
except ValueError:
print("The requested questionnaire name should be one of the following:")
print(QUESTIONNAIRE_IDS.keys())
else:
df_esm_selected = df_esm_preprocessed[df_esm_preprocessed["questionnaire_id"] == questionnaire_id]
df_esm_clean = clean_up_esm(df_esm_selected)
df_esm_clean.to_csv(snakemake.output[0])