<jupyter_start><jupyter_text>Calculate distance travelled?<jupyter_code>def main3(file):
    import pandas as pd
    
    #~~~~~~~~~~~~~(MAY NEED TO ALTER HERE)~~~~~~~~~~~~~~~
    #loading file from csv into pandas 
    b=pd.read_csv(file)
    #~~~~~~~~~~~~~(MAY NEED TO ALTER HERE)~~~~~~~~~~~~~~~
    
    
    ###PREPROCESSING
    
    
    #Removing instances where item quantity is 0
    #b=b[b['QTY']!=0]
    
    #getting columns we need
    if 'QTY' in b.columns:
        if 'PICKCOMPLETETIME' in b.columns:      
            df=b[['PICKCOMPLETETIME','BOXBARCODE','PRODUCTNAME','QTY']]
        else:
            df=b[['PICK_TIMESTAMP_LOCAL','BOXBARCODE','PRODUCTNAME','QTY']]
            df=df.rename(columns={'PICK_TIMESTAMP_LOCAL':'PICKCOMPLETETIME'})
            
            #changing time zone to UTC 
            df['PICKCOMPLETETIME']=pd.to_datetime(df['PICKCOMPLETETIME'])  #convert to datetime object
            df['PICKCOMPLETETIME']= df['PICKCOMPLETETIME'].dt.tz_localize(tz='US/Pacific') #localize to pacific
            df['PICKCOMPLETETIME']= df['PICKCOMPLETETIME'].dt.tz_convert(tz='UTC') #change to utc time
            df['PICKCOMPLETETIME']= df['PICKCOMPLETETIME'].dt.tz_localize(None) #remove time zone

            
            

    else:
        if 'PICKCOMPLETETIME' in b.columns:
            df=b[['PICKCOMPLETETIME','BOXBARCODE','PRODUCTNAME','PICKEDQTY']]
            df=df.rename(columns={'PICKEDQTY':'QTY'})
        else:
            df=b[['PICK_TIMESTAMP_LOCAL','BOXBARCODE','PRODUCTNAME','PICKEDQTY']]
            df=df.rename(columns={'PICKEDQTY':'QTY', 'PICK_TIMESTAMP_LOCAL':'PICKCOMPLETETIME'})
                        #changing time zone to UTC 
            df['PICKCOMPLETETIME']=pd.to_datetime(df['PICKCOMPLETETIME'])
            df['PICKCOMPLETETIME']= df['PICKCOMPLETETIME'].dt.tz_localize(tz='US/Pacific')
            df['PICKCOMPLETETIME']= df['PICKCOMPLETETIME'].dt.tz_convert(tz='UTC')
            df['PICKCOMPLETETIME']= df['PICKCOMPLETETIME'].dt.tz_localize(None) #remove time zone

            

    
    #concatenating all relevant columns into a single list in a column
    df['concat']=df.apply(lambda x: combine(x), axis=1)
    
    #removing all other columns except barboxcode and concat
    df=df[['BOXBARCODE','concat']]

    #grouping by boxbarcode and cooncatenating all the items in 'concat' into a list so you have lsits of products
    df=df.groupby('BOXBARCODE')['concat'].apply(list)
    df=df.reset_index(name='[Product, PickTime, QTY]')
    
    
    
    #MAIN ANALYSIS
    #returns dictionary with box ID's as keys and start times as values
    box_start_times=get_package_start_time(b)

    y=df.apply(lambda x:get_time_diff(x['BOXBARCODE'], x['[Product, PickTime, QTY]'],box_start_times), axis=1)
    
    #turn into dataframe where each row is an instance
    reformatted=[]
    for biglst in y:
        for lst in biglst:
            reformatted.append(lst)
    output_df= pd.DataFrame(reformatted, columns=['ProductName', 'TimeDelta', 'PickTime', 'QTY'])

    #Creates a dicitonary where keys are product names and values are list of product times
    
    #formatting df for output
    output_df['PickTime']=output_df['PickTime'].apply(lambda x: x.date())
    results=output_df.groupby(['ProductName','PickTime']).sum()
    results=results.reset_index()
    results=results.rename(columns={'TimeDelta':'TotalPickTime', 'PickTime':'Date','QTY':'TotalQuantity'})
    
    return results
    
results1=main3(file1)
#results1.to_csv('LA-Jan1-31-a.csv')
#results1.head()
results2=main3(file2)
results2.to_csv('PNW-Jan1-31.csv')
results2.head()
s=b['PICK_TIMESTAMP_LOCAL'].head()
s=pd.to_datetime(s)
s.dt.tz_localize(tz='US/Pacific')

b.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 1579589 entries, 0 to 1579588
Data columns (total 20 columns):
 #   Column                Non-Null Count    Dtype  
---  ------                --------------    -----  
 0   TIMESTAMP_UTC         1579589 non-null  object 
 1   PICK_TIMESTAMP_LOCAL  1579589 non-null  object 
 2   BOXBARCODE            1579216 non-null  object 
 3   BOXID                 1579589 non-null  int64  
 4   ORDER_ID              1579589 non-null  object 
 5   BOXINTIME             1579216 non-null  object 
 6   BOXOUTTIME            1577067 non-null  object 
 7   PICKORDERSUBMITTIME   1579589 non-null  object 
 8   PICKORDERSTARTTIME    1579571 non-null  object 
 9   PICKORDERENDTIME      1577440 non-null  object 
 10  DELIVERYDATE          1579589 non-null  object 
 11  PICKORDERQTY          1579589 non-null  float64
 12  PICKEDQTY             1579589 non-null  float64
 13  PRODUCTBARCODE        1579589 non-null  object 
 14  AREANAME              1579241 non-[...]<jupyter_text>Results  Exploration<jupyter_code>dict1=main3(file1)
results=main3(file)
results.to_csv('output.csv')
results.head()

results.to_csv('output2.csv')
la=pd.read_csv(file1)
la.head()
b1=la[la['BOXBARCODE']=='PRO_a829db9c-51a8-49fc-86e7-04680468ac05'].copy()
b1.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13478691774033696, 'fraction_numerical': 0.03944499504459861, 'mean_word_length': 3.0595333869670154, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '595549', 'license': 'MIT', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1750, 'n_words': 332, 'path': 'lyc-icee/Main3.ipynb', 'repo_name': 'oostendo/2022-SI699-011', 'size': '5045'}