<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 sys
sys.path.append('../')

# Import API key
from api_keys import g_key
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>weather_df = pd.read_csv(".././WeatherPy/weather.csv") 
#weather_df.head()
current = 0
coordinates = []
humidity = []
for index,row in weather_df.iterrows():
    lat = row['Latitude']
    lon = row['Longitude']
    Currentcoordinates = (lat, lon)
    coordinates.append(Currentcoordinates)
    humidity.append(row['Humidity'])
 
weather_df = weather_df.drop(['Unnamed: 0'],axis=1)

weather_df.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>figure_layout = {
    'width': '500px',
    'height': '500px',
    'border': '1px solid black',
    'padding': '1px',
    'margin': '0 auto 0 auto'
}
fig = gmaps.figure(layout=figure_layout)


heatmap_layer = gmaps.heatmap_layer(
    weather_df[['Latitude', 'Longitude']], weights=weather_df['Humidity'],
    max_intensity=20, point_radius=6.0)


fig.add_layer(heatmap_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>minTemp = 60
MaxTemp = 90
WindSpeedLimit = 5

figure_layout = {
    'width': '500px',
    'height': '500px',
    'border': '1px solid black',
    'padding': '1px',
    'margin': '0 auto 0 auto'
}
fig = gmaps.figure(layout=figure_layout)

weather_df = weather_df.dropna()
idealLocations1 = weather_df.loc[lambda df: weather_df['Temperature'] > minTemp]
idealLocations2 = weather_df.loc[weather_df['Temperature'] < MaxTemp ]
idealLocations2 = idealLocations2.merge(idealLocations1, how='inner')
idealLocationsFinal = idealLocations2
idealLocationsFinal = idealLocationsFinal.loc[idealLocationsFinal['Wind Speed'] > WindSpeedLimit]
heatmap_layer = gmaps.heatmap_layer(
    idealLocationsFinal[['Latitude', 'Longitude']], weights=idealLocationsFinal['Humidity'],
    max_intensity=30, point_radius=7.5)


fig.add_layer(heatmap_layer)

fig

#idealLocationsFinal.head(50)<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>url2 = f"https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=hotel&inputtype=textquery&fields=formatted_address,name&locationbias=circle:5000@47.6918452,-122.2226413&key={g_key}"
response2 = requests.get(url2).json()
print(response2['candidates'][0]['formatted_address'])
 
#https://maps.googleapis.com/maps/api/place/findplacefromtext/output?parameters
#https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=mongolian%20grill&inputtype=textquery&fields=photos,formatted_address,name,opening_hours,rating&locationbias=circle:2000@47.6918452,-122.2226413&key=YOUR_API_KEY

hotel_df = weather_df
hotel_df['Hotel Name'] = ''
hotel_df['City'] = ''
hotel_df['Country'] = ''
hotel_df['Formatted Address'] = ''

cities = []
countries = []
hotel_df = hotel_df.rename(columns={"Locations": "Location"})
formattedLocation = []
hotelName = []
for index, row in hotel_df.iterrows():
    latitude = row['Latitude']
    longitude = row['Longitude']
    
    
    url = f"https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=hotel&inputtype=textquery&fields=formatted_address,name&locationbias=circle:5000@{latitude},{longitude}&key={g_key}"
    response = requests.get(url).json()
    name = response['candidates'][0]['name'].title()
    formattedLocation.append(response['candidates'][0]['formatted_address'])
    hotelName.append(name)
    
    location = row['Location']
    location = location.split(",")
    country = location[1].upper()
    city = location[0].title()
    cities.append(city)
    countries.append(country)
   
hotel_df['Hotel Name'] = hotelName
hotel_df['Formatted Address'] = formattedLocation
hotel_df['City'] = cities
hotel_df['Country'] = countries
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>{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_info
# Add marker layer ontop of heat map


# Display figure

markers = gmaps.marker_layer(coordinates)
# Add the layer to the map
fig.add_layer(markers)
fig<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1312340735347652, 'fraction_numerical': 0.01983982526392428, 'mean_word_length': 5.920654911838791, 'pattern_counts': {'":': 1, '<': 36, '<?xml version=': 0, '>': 37, 'https://': 5, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '279938', 'license': 'ADSL', 'n_tokens_mistral': 1908, 'n_tokens_neox': 1797, 'n_words': 411, 'path': 'starter_code/VacationPy/VacationPy.ipynb', 'repo_name': 'jbeachy21/Python-api-challenge', 'size': '5494'}