<jupyter_start><jupyter_text>VacationPy---- Note* Instructions have been included for each segment. You do not have to follow them exactly, but they are included to help you think through the steps.<jupyter_code># Dependencies and Setup
import matplotlib.pyplot as plt 
import pandas as pd
import numpy as np
import requests
import gmaps
import os
from pprint import pprint

# Import API key
from config import g_key<jupyter_output><empty_output><jupyter_text>Store Part I results into DataFrame* Load the csv exported in Part I to a DataFrame<jupyter_code>cityWeatherDF = pd.read_csv("../output_data/city_weather.csv")
cityWeatherDF.head()<jupyter_output><empty_output><jupyter_text>Humidity Heatmap* Configure gmaps.* Use the Lat and Lng as locations and Humidity as the weight.* Add Heatmap layer to map.<jupyter_code># Access maps with unique API key
gmaps.configure(api_key = g_key)
cities = cityWeatherDF['City']
locations = cityWeatherDF[['Lat', 'Lng']]
weights = cityWeatherDF['Humidity']
# Customize the size of the figure
figure_layout = {
    'width': '1500px',
    'height': '800px',
    'border': '1px solid black',
    'padding': '1px',
    'margin': '0 auto 0 auto'
}
fig = gmaps.figure(layout=figure_layout, center = (40.71427, -74.00597), zoom_level = 4)

# Create heat layer
heat_layer = gmaps.heatmap_layer(locations, weights=weights, 
                                 dissipating=False, max_intensity=100,
                                 point_radius=1)

# Add layer
fig.add_layer(heat_layer)
fig<jupyter_output><empty_output><jupyter_text>Create new DataFrame fitting weather criteria* Narrow down the cities to fit weather conditions.* Drop any rows will null values.<jupyter_code># Ideal weather conditions are considered to be Max Temperature between 65F and 80F with 
#                Wind speed less than 10 mph and zero cloudiness

idealCityWeatherDF = cityWeatherDF.loc[((cityWeatherDF['Max Temp'] < 80) & (cityWeatherDF['Max Temp'] > 65))] \
                                .loc[(cityWeatherDF['Wind Speed'] < 10)] \
                                .loc[(cityWeatherDF['Cloudiness'] == 0)] \
                                .dropna()
idealCityWeatherDF<jupyter_output><empty_output><jupyter_text>Hotel Map* Store into variable named `hotel_df`.* Add a "Hotel Name" column to the DataFrame.* Set parameters to search for hotels with 5000 meters.* Hit the Google Places API for each city's coordinates.* Store the first Hotel result into the DataFrame.* Plot markers on top of the heatmap.<jupyter_code>hotel_df = idealCityWeatherDF.reset_index(drop=True)
hotel_df["Hotel Name"] = ""
hotel_df
# base_url
base_url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"

# geocoordinates
target_radius = 5000
target_type = 'lodging'
target_search = 'hotel'

# Loop through each City to identify the first hotel in the vicinity
for row in hotel_df.index:
    
    try:
        target_coordinates = f"{hotel_df.loc[row, 'Lat']}, {hotel_df.loc[row, 'Lng']}"

        # set up a parameters dictionary
        params = {
            "key": g_key,
            "location": target_coordinates,
            "radius": target_radius,
            "type": target_type,
            "keyword": target_search
        }

        # run a request using our params dictionary
        places_data = requests.get(base_url, params=params).json()

        hotel_name = places_data['results'][0]['name']
        print(f"Identified Hotel `{hotel_name}` in the City `{hotel_df.loc[row, 'City']}`")
    except:
        hotel_name = "COULD NOT FIND A MATCH!"
        print(f"SKIPPING.. Could not find hotel in the City `{hotel_df.loc[row, 'City']}`")
    
    hotel_df.loc[row, "Hotel Name"] = hotel_name
    hotel_name = ""

print("Hotel Data loaded successfully!")
hotel_df
# NOTE: Do not change any of the code in this cell

# Using the template add the hotel marks to the heatmap
info_box_template = """
<dl>
<dt>Name</dt><dd>{Hotel Name}</dd>
<dt>City</dt><dd>{City}</dd>
<dt>Country</dt><dd>{Country}</dd>
</dl>
"""
# Store the DataFrame Row
# NOTE: be sure to update with your DataFrame name
hotel_info = [info_box_template.format(**row) for index, row in hotel_df.iterrows()]
locations = hotel_df[["Lat", "Lng"]]
# Assign the marker layer to a variable
markers = gmaps.marker_layer(locations, info_box_content=hotel_info)

# Add the layer to the map
fig.add_layer(markers)
fig<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10812033476589007, 'fraction_numerical': 0.011762044786247455, 'mean_word_length': 3.739549839228296, 'pattern_counts': {'":': 5, '<': 37, '<?xml version=': 0, '>': 36, 'https://': 1, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '508022', 'license': 'Apache-2.0', 'n_tokens_mistral': 1449, 'n_tokens_neox': 1380, 'n_words': 425, 'path': 'VacationPy/VacationPy.ipynb', 'repo_name': 'skesamsetty/python-api-challenge', 'size': '4421'}