From 7a12f68dfe0f7a7aa32a73cd92642235740421cc Mon Sep 17 00:00:00 2001 From: junos Date: Fri, 11 Jun 2021 20:17:17 +0200 Subject: [PATCH] Fix a bug where evening EMAs where also reclassified as daytime. --- features/esm.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/features/esm.py b/features/esm.py index 2b9ba67..13e1474 100644 --- a/features/esm.py +++ b/features/esm.py @@ -196,7 +196,9 @@ def classify_sessions_by_completion_time( Returns ------- - object + df_session_counts_time: pd.DataFrame + A dataframe of all sessions (grouped by GROUP_SESSIONS_BY) with statuses, the number of items, + their time type (with some morning EMAs reclassified) and timestamp of first answer. """ df_session_counts = classify_sessions_by_completion(df_esm_preprocessed) @@ -204,8 +206,10 @@ def classify_sessions_by_completion_time( df_session_counts_time = df_session_time.join(df_session_counts) - df_session_counts_time.loc[ - df_session_counts_time.esm_session_count > MAX_MORNING_LENGTH, "time" - ] = "daytime" + morning_transition_to_daytime = (df_session_counts_time.time == "morning") & ( + df_session_counts_time.esm_session_count > MAX_MORNING_LENGTH + ) + + df_session_counts_time.loc[morning_transition_to_daytime, "time"] = "daytime" return df_session_counts_time