<jupyter_start><jupyter_text>WeatherPy---- 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 time
from scipy.stats import linregress

# Import API key
from api_keys import weather_api_key

# Incorporated citipy to determine city based on latitude and longitude
from citipy import citipy

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

# Range of latitudes and longitudes
lat_range = (-90, 90)
lng_range = (-180, 180)<jupyter_output><empty_output><jupyter_text>Generate Cities List<jupyter_code># List for holding lat_lngs and cities
lat_lngs = []
cities = []

# Create a set of random lat and lng combinations
lats = np.random.uniform(lat_range[0], lat_range[1], size=1500)
lngs = np.random.uniform(lng_range[0], lng_range[1], size=1500)
lat_lngs = zip(lats, lngs)

# Identify nearest city for each lat, lng combination
for lat_lng in lat_lngs:
    city = citipy.nearest_city(lat_lng[0], lat_lng[1]).city_name
    
    # If the city is unique, then add it to a our cities list
    if city not in cities:
        cities.append(city)

# Print the city count to confirm sufficient count
len(cities)<jupyter_output><empty_output><jupyter_text>Perform API Calls* Perform a weather check on each city using a series of successive API calls.* Include a print log of each city as it'sbeing processed (with the city number and city name).<jupyter_code># Save config information.
url = "http://api.openweathermap.org/data/2.5/weather?"
units = "imperial"

# Build partial query URLx
query_url = f"{url}appid={weather_api_key}&units={units}&q="
# print(query_url)


response = requests.get(query_url + '<NAME>').json()
print(response)<jupyter_output>{'coord': {'lon': -57.5575, 'lat': -38.0023}, 'weather': [{'id': 800, 'main': 'Clear', 'description': 'clear sky', 'icon': '01d'}], 'base': 'stations', 'main': {'temp': 54.03, 'feels_like': 52.2, 'temp_min': 52.88, 'temp_max': 56.23, 'pressure': 1023, 'humidity': 65}, 'visibility': 10000, 'wind': {'speed': 3, 'deg': 314, 'gust': 5.99}, 'clouds': {'all': 0}, 'dt': 1625494537, 'sys': {'type': 2, 'id': 264934, 'country': 'AR', 'sunrise': 1625483182, 'sunset': 1625517779}, 'timezone': -10800, 'id': 3430863, 'name': '<NAME>', 'cod': 200}<jupyter_text>Convert Raw Data to DataFrame* Export the city data into a .csv.* Display the DataFrame<jupyter_code>from datetime import date

today = date.today()
print("Today's date:", today)

# set up lists to hold reponse info
city_name = []
lat = []
lon = []
temp = []
temp_max = []
humidity = []
cloudiness = []
wind_speed = []

# Loop through the list of cities and perform a request for data on each
for city in cities:
    response = requests.get(query_url + city).json()
    print(f"city in: {city}")
    
    try:
#         get the country, date here and divide into set of 50 cities
        city_name.append(response['name'])
        lat.append(response['coord']['lat'])
        lon.append(response['coord']['lon'])
        temp.append(response['main']['temp'])
        temp_max.append(response['main']['temp_max'])
        humidity.append(response['main']['humidity'])
        cloudiness.append(response['clouds']['all'])
        wind_speed.append(response['wind']['speed'])

    except:
        print(f"The cities is not found")
#         print(f"The latitude information received is: {lat}")
#         print(f"The temperature information received is: {temp}")
#        ` print(f"The max temperature information received is: {temp_max}")
#         print(f"The longitude information received is: {lon}")
#         print(f"The humidity information received is: {humidity}")
#         print(f"The cloudiness information received is: {cloudiness}")
#         print(f"The wind speed information received is: {wind_speed}")
        
        pass

# create a data frame from cities, lat, and temp
city_dict = {
    "city": city_name,
    "lat": lat,
    "long": lon,
    "temp": temp,
    "temp_max": temp_max,
    "humidity": humidity,
    "cloudiness": cloudiness,
    "wind speed": wind_speed
}
city_data_df = pd.DataFrame(city_dict)
city_data_df<jupyter_output>Today's date: 2021-07-06
city in: nanortalik
city in: san jose
city in: tuatapere
city in: los llanos de aridane
city in: sao felix do xingu
city in: punta arenas
city in: albany
city in: ponta do sol
city in: lyuban
city in: kapaa
city in: smithers
city in: puerto ayora
city in: kurumkan
city in: gerede
city in: nizhneyansk
The cities is not found
city in: rikitea
city in: butaritari
city in: lebu
city in: port-gentil
city in: barrow
city in: tuktoyaktuk
city in: aurillac
city in: esperance
city in: comodoro rivadavia
city in: yeppoon
city in: bengkulu
city in: zhigansk
city in: kodiak
city in: jamestown
city in: port alfred
city in: khatanga
city in: shenjiamen
city in: berezovka
city in: atuona
city in: iquitos
city in: natal
city in: san patricio
city in: huarmey
city in: tshikapa
city in: lembeni
city in: jakar
city in: santa cruz de la palma
city in: ushuaia
city in: opuwo
city in: busselton
city in: bluff
city in: pathein
city in: barentsburg
The cities is not found
city in: cay[...]<jupyter_text>Inspect the data and remove the cities where the humidity > 100%.----Skip this step if there are no cities that have humidity > 100%.<jupyter_code>#  Get the indices of cities that have humidity over 100%.

# Make a new DataFrame equal to the city data to drop all humidity outliers by index.
# Passing "inplace=False" will make a copy of the city_data DataFrame, which we call "clean_city_data".<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11928360285167797, 'fraction_numerical': 0.025734654842636064, 'mean_word_length': 4.421300659754948, 'pattern_counts': {'":': 8, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, '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': '44586', 'license': 'ADSL', 'n_tokens_mistral': 2052, 'n_tokens_neox': 1910, 'n_words': 675, 'path': 'starter_code/WeatherPy.ipynb', 'repo_name': 'sammy10060102/api-challenge', 'size': '5765'}