<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
!jupyter nbextension enable --py gmaps<jupyter_output>Enabling notebook extension jupyter-gmaps/extension...
      - Validating: ok<jupyter_text>Store Part I results into DataFrame* Load the csv exported in Part I to a DataFrame<jupyter_code>city_data_csv = 'output_data/cities.csv'
city_data = pd.read_csv(city_data_csv)
city_data_df = pd.DataFrame(city_data)
city_data_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>gmaps.configure(api_key=g_key)

locations = city_data_df[['Latitude', 'Longitude']]
humidity = city_data_df['Humidity']
figure = gmaps.figure()

heatmap = gmaps.heatmap_layer(locations, weights=humidity, dissipating = False,
                              max_intensity = 250, point_radius = 4)

figure.add_layer(heatmap)
figure<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>#narrow max temp > 70 and < 80, wind speed less than 10, and zero cloudiness
narrowed_cities = city_data_df.loc[(city_data_df['Max Temperature'] < 80) & (city_data_df["Max Temperature"]                             
                                                                             > 70) & (city_data_df['Wind Speed'] < 10) & (city_data_df['Cloud %'] == 0)]
print(len(narrowed_cities))
narrowed_cities<jupyter_output>13<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>vacation_locations = narrowed_cities[['City','Latitude', 'Longitude','Country']]
vacation_lat = narrowed_cities['Latitude']
vacation_lon = narrowed_cities["Longitude"]
vacation_country = narrowed_cities['Country']
hotel_df = pd.DataFrame(narrowed_cities)
hotel_df["Hotel Name"] = ''
hotel_df
#this section is not working, I will try another approach. 
#Perhaps it is not working because of vacation_lat/lon not being iterated through.

#hotel_search_url = f'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={vacation_lat},{vacation_lon}&radius=5000&types=lodging&key={g_key}'
#for city in hotel_df.iterrows():
   # response = requests.get(hotel_search_url).json()
   # print(response)
#try using params to get the nearest hotels
params = {
    'radius' : 5000,
    'types'  : 'lodging',
    'key'    : g_key
}

places_url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?'

for index, place in hotel_df.iterrows():
    lat = place['Latitude']
    lon = place['Longitude']
    
    params['location'] = f'{lat},{lon}'
    try:
        hotel = requests.get(places_url, params=params).json()
        hotel_df.loc[index, 'Hotel Name'] = hotel['results'][0]['name']
    except:
        print('No result')

    
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[["Latitude", "Longitude"]]
# Add marker layer ontop of heat map
layer = gmaps.marker_layer(locations, info_box_content=hotel_info)

figure.add_layer(layer)

# Display figure
figure<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10967286420334196, 'fraction_numerical': 0.007531183807954813, 'mean_word_length': 4.599472990777339, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 35, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '656617', 'license': 'MIT', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1337, 'n_words': 386, 'path': 'VacationPy/VacationPy.ipynb', 'repo_name': 'dkoski23/python-api-challenge', 'size': '4249'}