Fix format specification.

master
junos 2023-05-16 17:22:09 +02:00
parent a7446cc34a
commit 0409c9e982
1 changed files with 5 additions and 2 deletions

View File

@ -213,7 +213,10 @@ def convert_event_time(df_esm_sam_clean: pd.DataFrame) -> pd.DataFrame:
df_esm_sam_clean["questionnaire_id"] == QUESTIONNAIRE_ID_SAM.get("event_time") df_esm_sam_clean["questionnaire_id"] == QUESTIONNAIRE_ID_SAM.get("event_time")
].assign( ].assign(
event_time=lambda x: pd.to_datetime( event_time=lambda x: pd.to_datetime(
x.esm_user_answer, errors="coerce", format="Y-m-d H:M:S %z", exact=True x.esm_user_answer,
errors="coerce",
format="%Y-%m-%d %H:%M:%S %z",
exact=True,
) )
) )
# Example answer: 2020-09-29 00:05:00 +0200 # Example answer: 2020-09-29 00:05:00 +0200
@ -249,7 +252,7 @@ def extract_event_duration(df_esm_sam_clean: pd.DataFrame) -> pd.DataFrame:
event_duration=lambda x: pd.to_datetime( event_duration=lambda x: pd.to_datetime(
x.esm_user_answer.str.slice(start=0, stop=-6), x.esm_user_answer.str.slice(start=0, stop=-6),
errors="coerce", errors="coerce",
format="Y-m-d H:M:S", format="%Y-%m-%d %H:%M:%S",
).dt.time ).dt.time
) )
# Example answer: 2020-09-29 00:05:00 +0200 # Example answer: 2020-09-29 00:05:00 +0200