<jupyter_start><jupyter_text>VacationPy---- Note* Keep an eye on your API usage. Use https://developers.google.com/maps/reporting/gmp-reporting as reference for how to monitor your usage and billing.* 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

# Import API key
from api_keys import g_key

#Configure google mapes with API 
gmaps.configure(api_key=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># Retrieve 
city_weather_file = "../cityweather.csv"
#Read CSV 
city_weather = pd.read_csv('cityweather.csv')
weather_df = city_weather.drop(columns=["Unnamed: 0"])
weather_df<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>#Configure google mapes with API 
gmaps.configure(api_key=g_key)
# Use latitude and longitude as locations
locations = weather_df[["Lat", "Lon"]]

#Add humidity layer to heatmap 
humidity = weather_df["Humidity"]
#Plotting heat map layer to map 
fig = gmaps.figure(center =  [0,0], zoom_level=2)

#Make heat map layer
heatmap_layer = gmaps.heatmap_layer(locations, weights=humidity,
                                    dissipating=False, max_intensity=5,
                                    point_radius=1)

fig.add_layer(heatmap_layer)

#Display
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>new_weather_df = pd.DataFrame(weather_df, columns =["Name", "Temp", "WindSpeed", "Clouds"])

temperature = (new_weather_df ["Temp"] <=80) & (new_weather_df["Temp"]>70)

wind_speed = new_weather_df["WindSpeed"]<10

cloudiness = new_weather_df["Clouds"]== 0

new_weather_df[temperature & wind_speed & cloudiness]
new_weather_df<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(weather_df, columns=["Name", "Lat", "Lon"])

hotel_df["Hotel Name"] = " "
hotel_df
#base url
base_url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"

params = {
    "type" : "hotel",
    "keyword" : "hotel",
    "radius" : 5000,
    "key" : g_key
}
for index, row in hotel_df.iterrows():
    lat = row["Lat"]
    lng = row["Lon"]
    city_name = row["Name"]
    
    params["location"] = f"{lat},{lng}"
    
    print(f"Retrieving Results for Index {index}: {city_name}.")
    response = requests.get(base_url, params=params).json()
    results = response['results']
    
    try: 
        print(f"Closest hotel in {city_name} is {results[0]['name']}.")
        hotel_df.loc[index, "Hotel Name"]= results[0]['name']
    except (KeyError, IndexError):
        print("Could not find result")
        print("------------------------")
        
       
    print("-----------------------Ending Search")
hotel_df.head()
# 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>{Name}</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", "Lon"]]
# Add marker layer ontop of heat map
# Display figure
markers = gmaps.marker_layer(locations)
fig.add_layer(markers)
fig<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12645673196131912, 'fraction_numerical': 0.005702950657079098, 'mean_word_length': 4.307894736842106, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 32, 'https://': 2, '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': '488155', 'license': 'ADSL', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1286, 'n_words': 386, 'path': 'VacationPy/VacationPy.ipynb', 'repo_name': 'jessicadoanes/python-api-challenge', 'size': '4033'}