<jupyter_start><jupyter_text>Important notes:Num enter = num submit + num quit--> When you enter, you either submit or you quit, so we know the time spend each time by using time submit - time enter before that.  Check time spend everyday by using enter, submit and quit<jupyter_code>df = df[df['action_type'].isin(['enter', 'submit', 'quit'])]
df.index = range(len(df))
df
df['time_session'] = df['timestamp'].diff().copy(deep=True)
df
df.to_csv('KT3_intermediate.csv', index=False)<jupyter_output><empty_output><jupyter_text>Restart the kernel and run above<jupyter_code>df = pd.read_csv('KT3_intermediate.csv')
df = df[df.index % 2 != 0]
df
df_groupby_result = df.groupby(['user_id', 'normalize_timestamp'],as_index=False)['time_session'].sum()
df_groupby_result['time_spend'] = (df_groupby_result['time_session'] / 1000).astype('int64')
df_groupby_result['day'] = df_groupby_result['normalize_timestamp']
df_groupby_result
df_groupby_result = df_groupby_result.drop(['normalize_timestamp', 'time_session'], axis=1)
df_groupby_result = df_groupby_result[['user_id', 'day', 'time_spend']]
df_groupby_result.to_csv('KT3_timespend_user_each_day.csv', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14501257334450965, 'fraction_numerical': 0.010058675607711651, 'mean_word_length': 8.95, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '332140', 'license': 'Apache-2.0', 'n_tokens_mistral': 434, 'n_tokens_neox': 419, 'n_words': 83, 'path': 'normalize_timestamp_timespend_each_day.ipynb', 'repo_name': 'anhtu96/personalized-learning-ko-hackathon', 'size': '1193'}