<jupyter_start><jupyter_text>VacationPy<jupyter_code>#List of dependencies
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import requests
import gmaps
import os

#Get access to map
from connect import google_string<jupyter_output><empty_output><jupyter_text>_Store WeatherPy results into DataFrame_<jupyter_code>#Bring in open weather data from WeatherPy results
cityweather = pd.read_csv(r'../WeatherPy/Results/citydata.csv')
cityweather.head()
#Find Humidity Max
hummax= cityweather.Humidity.astype(float).max()
hummax<jupyter_output><empty_output><jupyter_text>Humidity Heatmap<jupyter_code>#Use Googlemaps
gmaps.configure(api_key=google_string)
#Collect Latitudes and Longitudes to plot
locations = cityweather[["Lat","Lng"]]
#Collect Humidity for map weight and convert to float
humidity = cityweather["Humidity"].astype(float)
#Create Heatmap
fig = gmaps.figure(center=[13,4],zoom_level=2)

#Create heat weight layer
heat_layer = gmaps.heatmap_layer(locations, weights=humidity, dissipating=False, max_intensity=hummax, point_radius=3)

#Add heat weight layer
fig.add_layer(heat_layer)

#Display map
fig<jupyter_output><empty_output><jupyter_text>_Weather Criteria_<jupyter_code>#Create new data set with weather conditions
condition = cityweather.loc[(cityweather["Max Temp"] < 80) & (cityweather["Max Temp"] > 70) \
                            & (cityweather["Wind Speed"] < 10) \
                            & (cityweather["Cloudiness"] == 0)].dropna()
condition<jupyter_output><empty_output><jupyter_text>_Hotel Map_<jupyter_code>#Create new data set for hotels with perfect weather conditions
perfecthotels = condition[["City","Country", "Lat", "Lng"]].copy()
perfecthotels["Hotel Name"]=""
perfecthotels
#Create hotel parameters based on perfect weather conditions
destination = {"radius": 5000, "types": "lodging", "key": google_string}

#Iterate through the cities witht the perfect weather condition
for p, row in perfecthotels.iterrows():
    
    #Find through the latitudes and longitude
    lat = row["Lat"]
    lng = row["Lng"]
    
    #Use hotel parameters in search
    destination["location"] = f"{lat},{lng}"
    
    #Search url for hotels near cities with perfect weather condition
    googleurl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"
    
    #Get hotel names
    hotels = requests.get(googleurl, params=destination).json()
    
    #Find and store only one hotel from results
    try:
        perfecthotels.loc[p,"Hotel Name"] = hotels["results"][0]["name"]
    except (KeyError, IndexError):
        print(f"Hotel Not Found: for {perfecthotels.loc[p,'City']}.")

#New data set
perfecthotels
#Filter out cities with no hotel found
vacation = perfecthotels.loc[perfecthotels["Hotel Name"]!= ""]
vacation
#Format hotel markers for heatmap
hotel_marks = """
<dl>
<dt>Name</dt><dd>{Hotel Name}</dd>
<dt>City</dt><dd>{City}</dd>
<dt>Country</dt><dd>{Country}</dd>
</dl>
"""

#Data for marker layer rows
hotel_info = [hotel_marks.format(**row) for index, row in vacation.iterrows()]
locations = vacation[["Lat", "Lng"]]
#Placing marker layer ontop of heat map
marker_layer = gmaps.marker_layer(locations, info_box_content=hotel_info)
fig.add_layer(marker_layer)

#Show map
fig<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup