<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

# Output File (CSV)
output_data_file = "output_data/Hotels.csv"

# Import API key
from api_keys import g_key
hotel_df<jupyter_output><empty_output><jupyter_text>Store Part I results into DataFrame* Load the csv exported in Part I to a DataFrame<jupyter_code>city_data_file= "../output_data/cities.csv"
city_data_df = pd.read_csv(city_data_file)
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[['Lat','Lng']]
center_map = (0,0)

fig = gmaps.figure(map_type='ROADMAP')

heatmap_layer = gmaps.heatmap_layer(
    city_data_df[["Lat", "Lng"]], weights=city_data_df["Humidity"],
    max_intensity=100, point_radius=15)
fig = gmaps.figure(layout={'width' : '100%', 'height' : '675px'},center=(0,0),zoom_level=1.9)
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># narrow down weather df
# Max temp <80, Min temp >70, Cloudiness =0, Wind Speed <10mph
best_weather_df=city_data_df[city_data_df["Max Temp"] <75]
best_weather_df=best_weather_df[best_weather_df["Max Temp"] >55]
best_weather_df=best_weather_df[best_weather_df["Wind Speed"] <10]
best_weather_df=best_weather_df[best_weather_df["Cloudiness"]<1]
best_weather_df.dropna()
best_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 = best_weather_df
hotel_df["Hotel Name"] = ""
hotel_df.reset_index(inplace=True)
hotel_df.drop(columns='index')
lat = hotel_df["Lat"].astype(float)
lng = hotel_df["Lng"].astype(float)
hotel_df.head()
import pprint
lat = hotel_df["Lat"]
lng = hotel_df["Lng"]
hotels=[] 

for i in range (len(hotel_df)):
    target_type = "lodging"
    location = f"{lat[i]},{lng[i]}"
    keyword = "hotel"
    radius = 5000
    
    base_url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?"
    params= {
    "location" : location,
    "radius" : radius,
    "types" : target_type,
    "key" : g_key
    }
    
    try:
        response = requests.get(base_url, params=params).json()
        pprint(response)
        hotel_name = response
        hotels.append(hotel_name["results"][0]["name"])
        print(hotel_name["results"][0]["name"])
    except:
        hotels.append("")
        print("No result found. Skipping ... ")
        pass
# 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[["Lat", "Lng"]]
# Add marker layer ontop of heat map


# Display figure<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1226882000520969, 'fraction_numerical': 0.01067986454805939, 'mean_word_length': 5.2745098039215685, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 37, 'https://': 2, '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': '209670', 'license': 'ADSL', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1306, 'n_words': 350, 'path': 'VacationPy/.ipynb_checkpoints/VacationPy-checkpoint.ipynb', 'repo_name': 'wjriebel/Python-API-Challenge', 'size': '3839'}