<jupyter_start><jupyter_text>time each customer spent in the market:<jupyter_code>minutes_spend_list = []

# loop through the customer id columnn:
for cust in df['customer_id'].unique():
    df_at = df[df['customer_id']==cust] 
    
    # get first and last timestamp for current customer_id
    first_occ = df_at.timestamp[:1].values 
    last_occ = df_at.timestamp[-1:].values
    #print(first_occ, last_occ)
    
    # calculate time diff
    timediff = (last_occ - first_occ)/60000000000 # nanoseconds to minutes
    
    if timediff.tolist()[0] == 5775:
        print('customer', cust ,'spend', timediff.tolist()[0], 'minute(s) in the supermarket') 
    minutes_spend_list.append(timediff.tolist()[0])

average = sum(minutes_spend_list) / len(minutes_spend_list)
max_time = max(minutes_spend_list)
min_time = min(minutes_spend_list)

def most_common(lst):
    return max(set(lst), key=lst.count)

most_common_time = most_common(minutes_spend_list)

print(
    'The average time customers spend in the supermarket is: \n', 
      round(average, 2), 'minutes \n', 
    'The maximum time customers spend in the supermarket is: \n',
      round(max_time, 2), 'minutes \n', 
    'The minimum time customers spend in the supermarket is: \n',
      round(min_time, 2), 'minute(s) \n', 
    'The most commom time customers spend in the supermarket is: \n',
      round(most_common_time, 2), 'minute(s)  \n', 
     )<jupyter_output>The average time customers spend in the supermarket is: 
 6.26 minutes 
 The maximum time customers spend in the supermarket is: 
 52 minutes 
 The minimum time customers spend in the supermarket is: 
 1 minute(s) 
 The most commom time customers spend in the supermarket is: 
 1 minute(s)
{'fraction_non_alphanumeric': 0.1065812463599301, 'fraction_numerical': 0.0180547466511357, 'mean_word_length': 3.951008645533141, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '263221', 'license': 'MIT', 'n_tokens_mistral': 603, 'n_tokens_neox': 543, 'n_words': 171, 'path': '01_time_spend_in_supermarket.ipynb', 'repo_name': 'mscschliemann/customer_simulation', 'size': '1717'}