<jupyter_start><jupyter_text>Python API Analysis WeatherPy Analysis: 1. There seems to a visible temperature drop in the latitude range of 40-60 (Northern hemisphere). Also, every 20 degrees in latitude is roughly a 20 degrees drop in temperature(F). 2. The highest concentration of humidity appears to occur in cities located between the 40-60 latitude range (Northern hemisphere). I don't believe there is any relationship between latitude and cloudiness, but based on the plot graph, there are several cities that collect at 0%, 80% and 100%.3. Cities located in latitudes of the 40-60 range (Northern hemisphere) seem to report the highest wind speed.<jupyter_code># main dependencies
import pandas as pd
from citipy import citipy
import matplotlib.pyplot as plt
import random

# dependencies for OpenWeatherMap API
import json
import requests
from config import api_key
import numpy as np

# dependencies for plots
import time
# config info
url = "http://api.openweathermap.org/data/2.5/weather?"
units = "imperial" 
appid = api_key
settings = {"units": "imperial", "appid": api_key}
query_url = f"{url}appid={api_key}&units={units}&q="
query_url
#create empty lists
citylist = []
count = 0
dups = 'no'

for x in range(-90,90,1):
    for y in range(-180,180,1):
        city = citipy.nearest_city(x, y)
        city_dict = {}
        city_dict['city'] = city.city_name
        city_dict['country'] = city.country_code
        city_dict['lat'] = x
        city_dict['long'] = y
        if len(citylist) == 0:
            citylist.append(city_dict)
            count+=1
            continue
        else:
            # no dupes
            for city in citylist:
                if city['city'] == city_dict['city']:
                    dups = 'yes'
        if dups == 'no':
            citylist.append(city_dict)
            count+=1
        else:
            dups = 'no'

print(len(citylist))<jupyter_output>7957<jupyter_text>Generate Cities List<jupyter_code># get 50, then later 500 random cities / use list comprehension
citypd = pd.DataFrame({
    'city': [x['city'] for x in citylist],
    'country': [x['country'] for x in citylist],
})

citypd.head()

samplecity = citypd.sample(500)

# test city 45
# print(citylist[45])<jupyter_output><empty_output><jupyter_text>Perform API Calls<jupyter_code>count = 0
weather_json = []

for index,row in samplecity.iterrows():
    count+= 1
    query_url = url + "appid=" + api_key + "&units=" + units + "&q=" + row['city']
    try:
        weather_response = requests.get(query_url)
        cityweather = weather_response.json()
        weather_json.append(cityweather)
        city1 = data.get("name")
        city.append(city1)
        country1 = data.get("sys").get("country")
        country.append(country1)
    except:
        #print(f"No data for this city: {row['city']}")
        print(f"Processing Record {count}/500 | {row['city']}")
        print(query_url)

# print success note for a sanity check
print("-"*47)
print("                Data Collected")
print("-"*47)
# create place to store lists
city = []
country = []
latitude = []
longtitude = []

temperature = []
humidity = []

cloudiness = []
wind_speed = []
max_temp = []
for data in weather_json:
    try:
        weather_response = requests.get(query_url)
        cityweather = weather_response.json()
        lat1 = data.get("coord").get("lat")
        latitude.append(lat1)
        temp1 = data.get("main").get("temp")
        temperature.append(temp1)
        city1 = data.get("name")
        city.append(city1)
        country1 = data.get("sys").get("country")
        country.append(country1)
        humid1 = data.get("main").get("humidity")
        humidity.append(humid1)
        cloud1 = data.get("clouds").get("all")
        cloudiness.append(cloud1)
        wind1 = data.get("wind").get("speed")
        wind_speed.append(wind1)
        long1 = data.get("coord").get("lon")
        longtitude.append(long1)
        temps1 = data.get("main").get("temp_max")
        max_temp.append(temps1)
        
    except:
        pass

    continue

weather_dict = {"city":city, "Country":country, "Temperature (F)": temperature, "Latitude": latitude, "Longitude":longtitude,
                "Humidity": humidity, "Cloudiness":cloudiness,"Wind Speed":wind_speed, "Max_Temp":max_temp}
weather_df = pd.DataFrame(weather_dict)
weather_df.head(10)
weather_df.count()
weather_df.to_csv("WeatherPy.csv",encoding="utf-8",index=False)<jupyter_output><empty_output><jupyter_text>Latitude vs Temperature Plot<jupyter_code># latitude vs temp (F)
date = time.strftime("%m/%d/%Y")
plt.scatter(weather_df["Latitude"], 
            weather_df["Max_Temp"])
plt.title(f" Latitude vs. Max Temperature (F) {date}")
plt.ylabel("Max Temperature (F)")
plt.xlabel("Latitude")
plt.xlim((-90,90))
plt.grid(True)

plt.savefig("LatVsTemp_F.png")

plt.show()<jupyter_output><empty_output><jupyter_text>Latitude vs Humidity Plot<jupyter_code># latitude vs humidity (%)
plt.scatter(weather_df["Latitude"], 
            weather_df["Humidity"])
plt.title(f"Latitude vs. Humidity (%) {date}")
plt.ylabel("Humidity (%)")
plt.xlabel("Latitude")
plt.xlim((-90,90))
plt.grid(True)

plt.savefig("LatVsHumidity_percent.png")

plt.show()<jupyter_output><empty_output><jupyter_text>Latitude vs Cloudiness Plot<jupyter_code># latitude vs clouds (%)
plt.scatter(weather_df["Latitude"], 
            weather_df["Cloudiness"])
plt.title(f"Latitude vs. Cloudiness {date}")
plt.ylabel("Cloudiness (%)")
plt.xlabel("Latitude")
plt.xlim((-90,90))
plt.grid(True)

plt.savefig("LatVsClouds_percent.png")

plt.show()<jupyter_output><empty_output><jupyter_text>Latitude vs Wind Speed Plot<jupyter_code># latitude vs cloudiness (%)
plt.scatter(weather_df["Latitude"], 
            weather_df["Wind Speed"])
plt.title(f"Latitude vs. Wind Speed {date}")
plt.ylabel("Wind Speed (MPH)")
plt.xlabel("Latitude")
plt.xlim((-90,90))
plt.grid(True)

plt.savefig("LatVsWinds_MPH.png")

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14092276830491474, 'fraction_numerical': 0.018221330658642596, 'mean_word_length': 3.692549019607843, 'pattern_counts': {'":': 11, '<': 28, '<?xml version=': 0, '>': 28, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '18643', 'license': 'MIT', 'n_tokens_mistral': 2126, 'n_tokens_neox': 1959, 'n_words': 451, 'path': 'WeatherAPyI.ipynb', 'repo_name': 'risatino/PyAPI-WeatherPy', 'size': '5982'}