<jupyter_start><jupyter_text>0. Imports<jupyter_code>import pandas as pd<jupyter_output><empty_output><jupyter_text>1. Load csv<jupyter_code>df = pd.read_csv('/content/drive/MyDrive/Škola/WM/premenna_length/log_jeden_den.csv', ';', usecols=range(1,11))
df.head()<jupyter_output><empty_output><jupyter_text>2. Create a Length variable based on User_ID and 60 min.<jupyter_code>df['length'] = ''

for i, row in df.iterrows():
  if (i < len(df) - 1):
    if (df.at[i,'userid'] == df.at[i+1,'userid']):
      if ((df.at[i+1,'unixtime'] - df.at[i,'unixtime']) < 3600):
        df.at[i,'length'] = df.at[i+1,'unixtime'] - df.at[i,'unixtime']
      
df.head(15)<jupyter_output><empty_output><jupyter_text>3. Save to csv<jupyter_code>df.to_csv('Laca_premenna_length.csv', sep=';')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19676214196762143, 'fraction_numerical': 0.023661270236612703, 'mean_word_length': 6.178571428571429, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '183204', 'license': 'MIT', 'n_tokens_mistral': 368, 'n_tokens_neox': 352, 'n_words': 44, 'path': 'premenna_length/premenna_length.ipynb', 'repo_name': 'Ludovit-Laca/Web-mining', 'size': '803'}