From 224dedaced9ddcce37e8bba8378c1ce43b040a96 Mon Sep 17 00:00:00 2001 From: junos Date: Mon, 7 Jun 2021 16:50:27 +0200 Subject: [PATCH] Document the preprocess_esm function. --- features/esm.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/features/esm.py b/features/esm.py index 66dc82c..eb03119 100644 --- a/features/esm.py +++ b/features/esm.py @@ -35,6 +35,19 @@ def get_esm_data(usernames: Collection) -> pd.DataFrame: def preprocess_esm(df_esm: pd.DataFrame) -> pd.DataFrame: + """ + Convert timestamps into human-readable datetimes and expand the JSON column into several Pandas DF columns. + + Parameters + ---------- + df_esm: pd.DataFrame + A dataframe of esm data. + + Returns + ------- + df_esm_preprocessed: pd.DataFrame + A dataframe with added columns: datetime in Ljubljana timezone and all fields from ESM_JSON column. + """ df_esm["datetime_lj"] = df_esm["double_esm_user_answer_timestamp"].apply( lambda x: datetime.datetime.fromtimestamp(x / 1000.0, tz=TZ_LJ) )