<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 ipywidgets as widgets
import os

# Import API key
from api_keys 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>weatherdf = pd.read_csv('../WeatherPy/clean_data.csv')
weatherdf.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>gmaps.configure(g_key)
coordinates = weatherdf[["Latitude", "Longitude"]].astype(float)
# Plot Heatmap
fig = gmaps.figure()

# Create heat layer
heat_layer = gmaps.heatmap_layer(coordinates, weights=(weatherdf["Humidity"]), 
                                 dissipating=False, max_intensity=10,
                                 point_radius=1)


# Add layer
fig.add_layer(heat_layer)
plt.savefig("vacaheatmap.png")
# Display figure
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>lowwind1 = weatherdf.loc[weatherdf["Wind Speed"]<10,:]
nocloud2 = lowwind1.loc[lowwind1["Cloudiness"]==0,:]
nicetemp3 = nocloud2.loc[nocloud2["Max Temperature"]<80,:]
final4 = nicetemp3.loc[nicetemp3['Max Temperature']>70,:]

final4.head()<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 = pd.DataFrame(final4)
hotel_df['Hotel'] = ""
hotel_df
params = {
    "radius": 50000,
    "types": "hotel",
    "keyword": "hotel",
    "key": g_key
}

for index, row in hotel_df.iterrows():

    latitude = row['Latitude']
    longitude = row['Longitude']
    city = row['City']
    country = row['Country']
    
    params["location"] = f"{latitude},{longitude}"
    base_url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"
    # assemble url and make API request
    print(f"Retrieving Results for Index {index}: {city}.")
    response = requests.get(base_url, params=params).json()
    
    # extract results
    results = response['results']
    
    try:
        hotelname = response['results'][0]['name']
        print(f"Closest hotel to {city} at {latitude} , {longitude} is {hotelname}.")
        hotel_df.loc[index, "Hotel"] = hotelname
        
    except (KeyError, IndexError):
        print("Missing... skipping.")
        
    print("------------")
# 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}</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[["Latitude", "Longitude"]]
hotel_df.head()
## Add marker layer ontop of heat map
fig = gmaps.figure()

heat_layer = gmaps.heatmap_layer(locations, weights= (hotel_df["Humidity"]), 
                                 dissipating=False, max_intensity=10,
                                 point_radius=1)

marker_layer = gmaps.marker_layer(locations, hover_text='', label='', info_box_content=hotel_info)

fig.add_layer(heat_layer)
fig.add_layer(marker_layer)
plt.savefig("markermapvaca.png")

fig<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12452639555443294, 'fraction_numerical': 0.008840616317251832, 'mean_word_length': 4.238095238095238, 'pattern_counts': {'":': 4, '<': 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': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '620233', 'license': 'MIT', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1265, 'n_words': 342, 'path': 'VacationPyNB/VacationPy.ipynb', 'repo_name': 'kmanning1224/python-api-challenge', 'size': '3959'}