<jupyter_start><jupyter_text>Method Chaining The Analysis Pipeline<jupyter_code>import pandas as pd
import numpy as np 
import seaborn as sns 
import matplotlib.pyplot as plt
df = pd.read_csv('/Users/evanlewis/data301/Project/project-group53-project/data/raw/PRWI_Data.csv')
df
#This Method Chain is used to clean and process the data

lbls = ['Admin_Unit_Code', 'Sub_Unit_Code', 'Plot_Name', 'Location_Type', 'Date', 'Start_Time', 'End_Time', 'Observer', "Visit", 'NPSTaxonCode', "AOU_Code", 'PIF_Watchlist_Status', 'Regional_Stewardship_Status', 'Humidity', 'Sky', 'Wind', 'Initial_Three_Min_Cnt','Interval_Length','ID_Method','Distance','Flyover_Observed', 'Sex', 'Scientific_Name', 'AcceptedTSN','Disturbance']
bins = [0, 15, 20, 25, 35, np.inf]
names = ['<15', '15-20', '20-25', '25-35', '35+']
df = (
    pd.DataFrame(df.drop(labels = lbls,axis=1)
                 .rename(columns={'Site_Name':'Site','Common_Name':'Species'})
                .assign(Temp_Range=pd.cut(df['Temperature'], bins, labels=names)))
    )
df
# Now I'll put that chain into a function to be used in the future, and save it in the project_function.py file 

def clean_and_process(path):
    
    import numpy as np 
    import pandas as pd 
    
    df = (pd.read_csv(path))
    
    bins = [0, 10, 20, 30, 40, np.inf]
    names = ['<15', '15-20', '20-25', '25-35', '35+']
    lbls = ['Admin_Unit_Code', 'Sub_Unit_Code', 'Plot_Name', 'Location_Type', 'Date', 'Start_Time', 'End_Time', 'Observer', "Visit", 'NPSTaxonCode', "AOU_Code", 'PIF_Watchlist_Status', 'Regional_Stewardship_Status', 'Humidity', 'Sky', 'Wind', 'Initial_Three_Min_Cnt','Interval_Length','ID_Method','Distance','Flyover_Observed', 'Sex', 'Scientific_Name', 'AcceptedTSN','Disturbance']
    
    df_clean = (
        df.drop(labels = lbls,axis=1)
        .rename(columns={'Site_Name':'Site','Common_Name':'Species'})
        .assign(Temp_Range=pd.cut(df['Temperature'], bins, labels=names))
    )
    
    return df_clean<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17041479260369816, 'fraction_numerical': 0.02848575712143928, 'mean_word_length': 4.994011976047904, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '185013', 'license': 'MIT', 'n_tokens_mistral': 783, 'n_tokens_neox': 718, 'n_words': 152, 'path': 'analysis/Milestone 3 /Method_Chaining.ipynb', 'repo_name': 'data301-2021-summer2/project-group63-project', 'size': '2001'}