<jupyter_start><jupyter_text>Challenge Part 2: Have Customers Narrow Their Travel Searches Based on Temperature and Precipitation<jupyter_code>import pandas as pd
import requests
import gmaps

from config import g_key
city_data_df = pd.read_csv("./data/WeatherPy_Database.csv")
city_data_df
#To check the the Data Type
city_data_df.dtypes
#Configure Gmaps
gmaps.configure(api_key=g_key)
#Enter max temperature criteria
min_temp = float(input("what is the minimum temperature you would like for your vacation"))
max_temp = float(input("what is the maximum temperature you would like for your vacation"))
# Ask the customer if you want it to be raining 
rain_amount = input ("Do you want it to be raining?(yes/no)")
snow_amount = input("Do you want it to be snowing (yes/no)")
if rain_amount == "no" and snow_amount == "no":
    filtered_cities_df=city_data_df.loc[(city_data_df["Max Temp"]<=max_temp)&
                                       (city_data_df["Max Temp"]>=min_temp)&
                                       (city_data_df["Rain (inches)"]==0)&
                                       (city_data_df["Snow (inches)"]==0)]
elif rain_amount =="no" and snow_amount =="yes":
    filtered_cities_df=city_data_df.loc[(city_data_df["Max Temp"]<=max_temp)&
                                       (city_data_df["Max Temp"]>=min_temp)&
                                       (city_data_df["Rain (inches)"]==0)&
                                       (city_data_df["Snow (inches)"]>=0.0)]
elif rain_amount =="yes" and snow_amount =="no":
    filtered_cities_df=city_data_df.loc[(city_data_df["Max Temp"]<=max_temp)&
                                       (city_data_df["Max Temp"]>=min_temp)&
                                       (city_data_df["Rain (inches)"]>=0.0)&
                                       (city_data_df["Snow (inches)"]==0)]

else:
    filtered_cities_df=city_data_df.loc[(city_data_df["Max Temp"]<=max_temp)&
                                       (city_data_df["Max Temp"]>=min_temp)&
                                       (city_data_df["Rain (inches)"]>=0.0)&
                                       (city_data_df["Snow (inches)"]==0)]
filtered_cities_df.head()
#Count the cities
filtered_cities_df.count()
# To drop the NA cities and run the code to make sure if any city dropped
filtered_cities_df = filtered_cities_df.dropna()
filtered_cities_df.head()
# After dropping the NA cities count it one more time to see how may cities are dopped.
# we can see the number did not change, that mean no city was dopped. 
filtered_cities_df.count()
#Add the cities to a marker layer map with a pop-up marker for each city that includes:
#Hotel name
#City
#Country
#Current weather description with the maximum temperature

hotel_df = filtered_cities_df[["City","Country", "Max Temp", "Lat", "Lng"]].copy()
hotel_df["Hotel Name"] = " "
hotel_df.head()
# Setting the parameters. these are the settings for gmaps.

params = {
    "radius": 5000,
    "type": "lodging",
    "key": g_key
}

#Iterete through

for index, row in hotel_df.iterrows():
    lat = row["Lat"]
    lng =row["Lng"]
    
    params["location"]=f"{lat},{lng}"
    
    base_url="https://maps.googleapis.com/maps/api/place/nearbysearch/json"
    
    hotels = requests.get(base_url, params=params).json()
    
    try:
        hotel_df.loc[index, "Hotel Name"] = hotels["results"][0]["name"]
    
    except IndexError:
        print ("Hotel name Not Found .....Keep skipping....")

hotel.df.head()
output_data_file="./data/WeatherPy_Cacation.csv"
hotel_df.to_csv(output_data_file, index_label="city_ID")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12323456106341733, 'fraction_numerical': 0.004707837164220438, 'mean_word_length': 2.8343949044585988, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '305662', 'license': 'MIT', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1134, 'n_words': 288, 'path': '.ipynb_checkpoints/Vacation_Search-checkpoint.ipynb', 'repo_name': 'RDeep1986/World_Weather_Challenge-', 'size': '3611'}