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