<jupyter_start><jupyter_text>Notebook Objectives The objective of this notebook is to create a function that creates a square area based upon a users lat/long coordinates and the desired size (in miles) of the area.<jupyter_code>import pandas as pd
# Import cleaned csv files
df_rest = pd.read_csv("CSVs/Rest_Stop_API.csv")
df_walmart = pd.read_csv("CSVs/Walmart_API.csv")
df_weigh = pd.read_csv("CSVs/Weigh_Station_API.csv")

df.head()
def location_finder(df, latitude, longitude, distance):
    """
    Returns places of interest within a designated area for a users specific geographic coordinates.
    
    Parameters:
        df (Pandas DataFrame): DataFrame containing places of interest and their corresponding lat/long coordinates
        latitude (Float value): Users designated latitude
        longitude (Float value): Users designated longitude
        distance (Int): Value that determines the search area size for designated place of interest
        
    Returns:
        df (Pandas DataFrame): DataFrame containing only the places of interest that are within the user's designated search area
    
    
    """
    
    # Each lat/long degree is ~69.2 miles
    geo_dist = distance / 69.2

    # Creates boundary limits on the latitude parallel
    lat_plus = lat + geo_dist
    lat_minus = lat - geo_dist

    # Creates boundary limits on the longitude parallel
    long_plus = long + geo_dist
    long_minus = long - geo_dist
    
    long_list = []
    lat_list = []

    # Append to list the longitude coordinates that fall within boundary limits
    for i in df['Longitude']:
        if i < long_plus:
            if i > long_minus:
                long_list.append(i)
    
    # Create new dataframe containing only rows containing longitude's within long_list
    df_long = df.loc[df['Longitude'].isin(long_list)]

    # Append to list the latitude coiordinates that fall within boundary limits
    for i in df_long['Latitude']:
        if i < lat_plus:
            if i > lat_minus:
                lat_list.append(i)
                
    # Create final dataframe containing only rows containing latitude's within lat_list 
    df_final = df_long.loc[df_long['Latitude'].isin(lat_list)]
    
    df_final = df_final.drop('Unnamed: 0', axis=1)
    
    return df_final

# Function for rest areas using my current lat/long coordinates
df_rest = location_finder(df_rest, 41.840562, -87.659957, 20)
df_rest.head()
# Test function on walmart dataset
df_walmart = location_finder(df_walmart, 41.840562, -87.659957, 5)
# Function appears to be working properly
df_walmart<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06990068754774637, 'fraction_numerical': 0.016424751718869365, 'mean_word_length': 3.18370607028754, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '69224', 'license': 'MIT', 'n_tokens_mistral': 793, 'n_tokens_neox': 733, 'n_words': 267, 'path': 'Notebooks/connor_notebooks/API_Coordinates_Test.ipynb', 'repo_name': 'standroidbeta/data-science', 'size': '2618'}