<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

# 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>file = "../WeatherPy/output/cities.csv"

cities_df =  pd.read_csv(file)
cities_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>locations = cities_df[["lat", "lon"]]
humidity = cities_df["humidity"].astype(float)

fig = gmaps.figure(map_type="TERRAIN")

heat_layer = gmaps.heatmap_layer(locations, weights=humidity,
                                dissipating=False, max_intensity=100,
                                point_radius=1)

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>temp_vacation = cities_df.loc[(cities_df['temp_min']>=60)&(cities_df['temp_min']<=90)]
wind_file = temp_vacation.loc[(temp_vacation['wind_speed']<=30)]
weather = wind_file.loc[(wind_file['cloudiness']<=30)]
print(weather.head())
len(weather)<jupyter_output>cities  cloudiness country        date  humidity    lat     lon  \
5     oriximina          23      BR  1578278765        76  -1.77  -55.87   
10      kahului          20      US  1578278479        65  20.89 -156.47   
17  new norfolk          20      LR  1578278497        88   6.65  -10.59   
19    busselton          23      AU  1578278766        12 -33.64  115.35   
31       hobart          20      AU  1578278744        55 -42.88  147.33   

    temp_max  temp_min  wind_speed  
5      79.88     79.88        2.08  
10     77.00     72.00       18.34  
17     68.00     68.00        3.36  
19     90.00     82.99       11.43  
31     78.01     66.20       16.11<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 = weather.reset_index(drop=True)
hotel_df['Hotel Name']=""
hotel_df.head()
base_url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"
params ={
        "radius":5000,
        "types": "Hotel",
        "keyword": "Lodging",
        "key":g_key
}
for index,row in hotel_df.iterrows():
    plat = row['lat']
    plng = row['lon']
    params['location'] = f"{plat},{plng}"
    response = requests.get(base_url,params=params).json()
    results = response['results']
    try:
        #print(results[0]['name'])
        hotel_df.loc[index, "Hotel Name"] = results[0]['name']
    except:
        #print(f"City not found")
        hotel_df.loc[index, "Hotel Name"] = print(np.nan)
    continue

print(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>{cities}</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", "lon"]]
# Add marker layer ontop of heat map
markers = gmaps.marker_layer(locations,info_box_content=[f"Hotel loc: {rate}" for rate in hotel_info])
fig.add_layer(markers)
# Display Map
fig

# Display Map<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11186868686868687, 'fraction_numerical': 0.05277777777777778, 'mean_word_length': 3.286796536796537, 'pattern_counts': {'":': 4, '<': 37, '<?xml version=': 0, '>': 35, 'https://': 1, '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': '323784', 'license': 'ADSL', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1324, 'n_words': 367, 'path': 'VacationPy/VacationPy.ipynb', 'repo_name': 'bandipara/python-api-challenge', 'size': '3960'}