<jupyter_start><jupyter_text>Create a Customer travel Destinations Map<jupyter_code># Dependencies and Setup
import pandas as pd
import requests
import gmaps
import numpy as np

# Import API key
from config import g_key

# Configure gmaps API key
gmaps.configure(api_key=g_key)
#Import the WeatherPy_database.csv file 
city_data_df = pd.read_csv("../Weather_Database/WeatherPy_database.csv")
city_data_df.head()
# Ask the user to add a minimum and maximum temperature value
min_temp = float(input("What is the minimum temperature you would like for your trip? "))
max_temp = float(input("What is the maximum temperature you would like for your trip? "))
# Filter the dataset to find the cities that fit the criteria.
preferred_cities_df = city_data_df.loc[(city_data_df["Max Temp"] <= max_temp) & \
                                       (city_data_df["Max Temp"] >= min_temp)]
# Determine if there are empty rows
preferred_cities_df.count()
# get rid of rows with empty cells
preferred_cities_df.dropna(inplace = True)
preferred_cities_df.count()
# Create DataFrame called hotel_df to store hotel names along with city, country, max temp, and coordinates
hotel_df = preferred_cities_df[["City", "Country", "Max Temp", "Current Description", "Lat", "Lng"]].copy()

# Create a new column "Hotel Name"
hotel_df["Hotel Name"] = ""
hotel_df.head(10)
# Set parameters to search for hotels within 5000 meters
params = {
    "radius": 5000,
    "type": "lodging",
    "key": g_key
}

# Iterate through the DataFrame.
for index, row in hotel_df.iterrows():
    # Get the latitude and longitude.
    lat = row["Lat"]
    lng = row["Lng"]

    # Add the latitude and longitude to location key for the params dictionary.
    params["location"] = f"{lat},{lng}"

    # Use the search term: "lodging" and our latitude and longitude.
    base_url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"
    # Make request and get the JSON data from the search.
    hotels = requests.get(base_url, params=params).json()
    # Grab the first hotel from the results and store the name.
    try:
        hotel_df.loc[index, "Hotel Name"] = hotels["results"][0]["name"]
    except (IndexError):
        print("Hotel not found... skipping.")
# get rid of empty cells
nan_value = float("NaN")

hotel_df_clean.replace("", nan_value, inplace=True)

hotel_df_clean.dropna(subset = ["Hotel Name"], inplace=True)


# Export the City_Data into a csv
output_data_file = "WeatherPy_vacation.csv"
hotel_df_clean.to_csv(output_data_file, index_label = "City_ID")
# Add city name, the country code, the weather description and maximum temperature for the city
# to info box template
info_box_template = """
<dl>
<dt>Hotel Name</dt><dd>{Hotel Name}</dd>
<dt>City</dt><dd>{City}</dd>
<dt>Country</dt><dd>{Country}</dd>
<dt>Current Weather</dt><dd>{Current Description} and {Max Temp} <span>&#176</span>F</dd>

</dl>
"""
#<dt>Max Temp</dt><dd>{Max Temp} °F</dd>
# Get the data from each row and add it to the formatting template and store the data in a list.
hotel_info = [info_box_template.format(**row) for index, row in hotel_df_clean.iterrows()]

# Get the latitude and longitude from each row and store in a new DataFrame.
locations = hotel_df_clean[["Lat", "Lng"]]
# Add marker layer for each city type to the map
locations = hotel_df[["Lat", "Lng"]]

fig = gmaps.figure(center=(30.0, 31.0), zoom_level=1.5)

marker_layer = gmaps.marker_layer(locations, info_box_content=hotel_info)

fig.add_layer(marker_layer)

fig<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1191151446398185, 'fraction_numerical': 0.006239364719228588, 'mean_word_length': 4.66131621187801, 'pattern_counts': {'":': 3, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '477093', 'license': 'MIT', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1130, 'n_words': 368, 'path': 'Vacation_Search/Vacation_Search.ipynb', 'repo_name': 'ellraff/World_Weather_Analysis', 'size': '3526'}