Summary


This assignment required me to leverage csv, randomly generated numbers, and an online API to conduct exploratory analyses on weather patterns across hundreds of cities.


After importing my dependencies and entering my API key into a file I created called "api_keys", I initialized some list variables, and used numpy to generate random latitudes and longitudes to fill one of the lists. Then, I used citypy to find the nearest city to each latitude and logitude. Next, I used the openweathermap API to obtain data for several weather dimensions across a single timepoint. Finally, I created scatterplots of those weather dimensions against the cities generated earlier. For a fully deployed webpage that showcases the scatterplots created in this notebook, click here.

Solution


WeatherPy


Analysis

  • As expected, the weather becomes significantly warmer as one approaches the equator (0 Deg. Latitude). More interestingly, however, is the fact that the southern hemisphere tends to be warmer this time of year than the northern hemisphere. This may be due to the tilt of the earth.
  • There is no strong relationship between latitude and cloudiness. However, it is interesting to see that a strong band of cities sits at 0, 80, and 100% cloudiness.
  • There is no strong relationship between latitude and wind speed. However, in northern hemispheres there is a flurry of cities with over 20 mph of wind.

In [3]:
# Dependencies and Setup
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import requests
import time
from pprint import pprint

# Import API key
from api_keys import 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)
In [4]:
print(api_key)
d2f3c9adb0ac34504aca3d67da74fa27

Generate Cities List

In [5]:
# List for holding lat_lngs and cities
lat_lngs = []
cities = []

# Create a set of random lat and lng combinations
lats = np.random.uniform(low=-90.000, high=90.000, size=1500)
lngs = np.random.uniform(low=-180.000, high=180.000, 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)
Out[5]:
608
In [6]:
print(cities)
['rolim de moura', 'provideniya', 'tsihombe', 'yamada', 'pevek', 'chuy', 'iquitos', 'punta arenas', 'taolanaro', 'hurricane', 'butaritari', 'torit', 'saint george', 'mayo', 'chokurdakh', 'castro', 'geraldton', 'sambava', 'aklavik', 'ocara', 'guantanamo', 'codrington', 'artyom', 'rikitea', 'safaqis', 'nishihara', 'mogadouro', 'luoyang', 'tuktoyaktuk', 'mataura', 'nizwa', 'hovd', 'port alfred', 'salalah', 'yerofey pavlovich', 'lavrentiya', 'verkhnedneprovskiy', 'jinxiang', 'ushuaia', 'hobart', 'margate', 'jamestown', 'new norfolk', 'nome', 'mys shmidta', 'kaohsiung', 'asau', 'kapaa', 'englewood', 'port elizabeth', 'nuuk', 'broome', 'qala', 'deputatskiy', 'yellowknife', 'satitoa', 'bluff', 'arraial do cabo', 'vaini', 'macaboboni', 'berlevag', 'rosiori', 'saleaula', 'port-cartier', 'ahuimanu', 'valparaiso', 'belushya guba', 'ponta do sol', 'hermanus', 'buraydah', 'zhoucheng', 'port hawkesbury', 'luderitz', 'mato verde', 'kusa', 'atar', 'poum', 'portland', 'ancud', 'paita', 'xingtai', 'si satchanalai', 'havelock', 'lazaro cardenas', 'bengkulu', 'quatre cocos', 'paraiso', 'tura', 'husavik', 'lebu', 'waingapu', 'saint-pierre', 'sentyabrskiy', 'bredasdorp', 'illoqqortoormiut', 'hofn', 'puerto ayora', 'raga', 'nara', 'chara', 'bilibino', 'busselton', 'kodiak', 'lata', 'krivopolyanye', 'jalingo', 'zhigansk', 'cherskiy', 'khani', 'albany', 'torbay', 'avarua', 'cape town', 'qaanaaq', 'vila velha', 'cidreira', 'yulara', 'rameswaram', 'bambanglipuro', 'guiratinga', 'carnarvon', 'grand river south east', 'constantine', 'tasiilaq', 'longyearbyen', 'sao joao de pirabas', 'matara', 'hithadhoo', 'atikokan', 'khonuu', 'sibu', 'atuona', 'louisbourg', 'port hedland', 'renukut', 'vanderhoof', 'yeppoon', 'safwah', 'tiznit', 'brae', 'georgetown', 'hilo', 'nizhniy tsasuchey', 'kavieng', 'haljala', 'rawson', 'havre-saint-pierre', 'mezen', 'half moon bay', 'sao filipe', 'mount gambier', 'bethel', 'roswell', 'ilhabela', 'maragogi', 'palabuhanratu', 'amahai', 'mar del plata', 'cayenne', 'gigmoto', 'bengkalis', 'nanakuli', 'snasa', 'souillac', 'aykhal', 'ahipara', 'kushima', 'san patricio', 'cabo san lucas', 'makungu', 'port lincoln', 'hamilton', 'saint-philippe', 'attawapiskat', 'mahajanga', 'dingle', 'sangar', 'sao felix do xingu', 'nouadhibou', 'kirakira', 'urumqi', 'ituni', 'airai', 'esperance', 'jacqueville', 'teya', 'bilma', 'bulgan', 'tual', 'nichinan', 'vallenar', 'thompson', 'donduseni', 'severo-kurilsk', 'narsaq', 'elizabethton', 'malakal', 'laguna', 'arawa', 'sechura', 'coahuayana', 'klaksvik', 'nikolskoye', 'creel', 'dawei', 'lovozero', 'norman wells', 'mehamn', 'flin flon', 'ilulissat', 'samusu', 'katsuura', 'ust-koksa', 'kalianget', 'plettenberg bay', 'la orilla', 'te anau', 'pangody', 'okhotsk', 'hargeysa', 'moses lake', 'kaitangata', 'pisco', 'gallipoli', 'tall kayf', 'killybegs', 'coihaique', 'ngorongoro', 'belmonte', 'leningradskiy', 'kavaratti', 'isangel', 'mahebourg', 'manta', 'hualmay', 'faya', 'east london', 'leo', 'comodoro rivadavia', 'shitanjing', 'iqaluit', 'upernavik', 'floro', 'barentsburg', 'cap malheureux', 'awbari', 'narathiwat', 'tsuruga', 'huarmey', 'yanan', 'hami', 'petropavlovsk-kamchatskiy', 'lasa', 'fort nelson', 'tilichiki', 'yuli', 'altay', 'wolkersdorf', 'samarai', 'riohacha', 'sao joao da barra', 'labytnangi', 'chumikan', 'komsomolskiy', 'dikson', 'soyo', 'mareeba', 'baturaja', 'innisfail', 'chato', 'waipawa', 'bereda', 'bathsheba', 'macau', 'constitucion', 'manzanillo', 'yurginskoye', 'avera', 'oda', 'amderma', 'marcona', 'khatanga', 'chicama', 'clyde river', 'black forest', 'sangareddi', 'pontianak', 'pangai', 'the valley', 'namibe', 'necochea', 'puerto carreno', 'labuhan', 'barrow', 'tigil', 'phra phutthabat', 'tessalit', 'sao joao da ponte', 'leh', 'megion', 'macenta', 'viedma', 'kahului', 'matagami', 'udachnyy', 'abu zabad', 'kolda', 'sivas', 'mokhos', 'aborlan', 'nizhneyansk', 'beloha', 'ribeira grande', 'hasaki', 'vestmannaeyjar', 'cam pha', 'bambous virieux', 'hihifo', 'tiksi', 'chany', 'lolua', 'grindavik', 'boyolangu', 'evenskjaer', 'bandarbeyla', 'rungata', 'naze', 'krishnarajpet', 'pemangkat', 'lagoa', 'birjand', 'wazzan', 'port hardy', 'adrar', 'belyy yar', 'warrnambool', 'veraval', 'nemuro', 'gobabis', 'bokovskaya', 'fortuna', 'timaru', 'umzimvubu', 'magdagachi', 'saskylakh', 'port blair', 'dicabisagan', 'talnakh', 'villaviciosa', 'xai-xai', 'sitka', 'sur', 'cururupu', 'tuatapere', 'galveston', 'deniliquin', 'tucurui', 'mount isa', 'san cristobal', 'chagda', 'touros', 'ambilobe', 'inhambane', 'tiarei', 'hambantota', 'riberalta', 'kaduqli', 'solnechnyy', 'drumheller', 'erenhot', 'tomino', 'mikkeli', 'novyy karachay', 'bassila', 'ilinskiy', 'wakkanai', 'presidencia roque saenz pena', 'antalaha', 'axim', 'alice springs', 'zafra', 'makat', 'saldanha', 'kazalinsk', 'pala', 'sorland', 'kathmandu', 'wewak', 'vestmanna', 'dabakala', 'qaqortoq', 'iwanai', 'huacho', 'south lake tahoe', 'faanui', 'anloga', 'arica', 'andenes', 'guanare', 'tondano', 'smithers', 'barahona', 'newnan', 'tivoli', 'helong', 'vila franca do campo', 'corinto', 'seydisehir', 'bernardino de campos', 'pecos', 'grand centre', 'raub', 'kiruna', 'goderich', 'waspan', 'mentana', 'gudivada', 'harper', 'victoria', 'westport', 'balykshi', 'awjilah', 'olavarria', 'riverton', 'vilhena', 'semey', 'palana', 'tongliao', 'la ronge', 'iquique', 'grand gaube', 'pontes e lacerda', 'svetlogorsk', 'collie', 'baruun-urt', 'yantal', 'pangnirtung', 'douentza', 'monrovia', 'ndele', 'warqla', 'braslav', 'astoria', 'luena', 'roma', 'dayong', 'byron bay', 'sun valley', 'shingu', 'taitung', 'phan thiet', 'tombouctou', 'mackay', 'marzuq', 'barra do garcas', 'yialos', 'henties bay', 'san rafael', 'praia', 'sassandra', 'manaure', 'santo estevao', 'myitkyina', 'balaghat', 'verkhnyaya inta', 'stornoway', 'dossor', 'piracuruca', 'rayevskiy', 'mehkar', 'amurrio', 'ulladulla', 'kanniyakumari', 'zarubino', 'santa luzia', 'kindu', 'korla', 'marsh harbour', 'barentu', 'buon me thuot', 'tumannyy', 'cedar city', 'springdale', 'hellvik', 'illela', 'jiangyou', 'monywa', 'maroantsetra', 'grants', 'methoni', 'general roca', 'ongandjera', 'mariental', 'lake cowichan', 'anadyr', 'karratha', 'paamiut', 'falam', 'kaeo', 'ofunato', 'maningrida', 'muros', 'qandala', 'bonavista', 'beyneu', 'melnikovo', 'muhos', 'noyabrsk', 'hauterive', 'chifeng', 'srednekolymsk', 'alofi', 'alyangula', 'tlalcilalcalpan', 'sisimiut', 'mangai', 'vieques', 'puerto escondido', 'bhag', 'kieta', 'toftir', 'thinadhoo', 'bay city', 'kungurtug', 'tumut', 'caravelas', 'ryde', 'murchison', 'madaoua', 'den helder', 'sabratah', 'neftekumsk', 'ponta delgada', 'kopavogur', 'maridi', 'rocha', 'jumla', 'neiafu', 'miranda', 'zheleznodorozhnyy', 'lekhovon', 'mount darwin', 'kosh-agach', 'lidkoping', 'namatanai', 'bocaranga', 'jacareacanga', 'vardo', 'meulaboh', 'alibag', 'ukiah', 'ulaangom', 'yirol', 'broken hill', 'pueblo nuevo', 'novaya ladoga', 'les cayes', 'muscat', 'moree', 'uruzgan', 'fairbanks', 'camacha', 'olinda', 'college', 'kerrville', 'guerrero negro', 'catuday', 'ruatoria', 'flinders', 'sagar', 'shatalovo', 'bacolod', 'portadown', 'san quintin', 'pampa', 'washington', 'utiroa', 'belaya gora', 'khandyga', 'nago', 'lethem', 'karasjok', 'reconquista', 'aripuana', 'buin', 'teknaf', 'baleshwar', 'presidente epitacio', 'yashan', 'zelenoborskiy', 'koboldo', 'cabatuan', 'nhlangano', 'gat', 'madang', 'pirapora', 'tucuma', 'fare', 'stefanesti', 'ullapool', 'rundu', 'konevo', 'copiapo', 'basco', 'maues', 'baykit', 'ksenyevka', 'pingyin']

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).
In [9]:
url = "http://api.openweathermap.org/data/2.5/weather?"
units = "metric"

# Build partial query URL
query_url = f"{url}appid={api_key}&units={units}&q="
print(query_url)
http://api.openweathermap.org/data/2.5/weather?appid=d2f3c9adb0ac34504aca3d67da74fa27&units=metric&q=
In [10]:
city_list = []
lat_list = []
lng_list = []
max_temp_list = []
humidity_list = []
cloudiness_list = []
windspeed_list = []
counter = 0
record_counter = 0
setcount = 1


for city in cities:
    counter += 1
    if (counter % 50 == 0):
        setcount += 1
        record_counter = 0
        print(setcount)
        print(record_counter)
        print(counter)
    record_counter += 1
    print("processing Record " + str(record_counter) + " of Set " + str(setcount) + " | " + city)
    try:
        weather_response = requests.get(query_url + city).json()
        #pprint(weather_response)
        city_list.append(weather_response['name'])
        lat_list.append(weather_response['coord']['lat'])
        lng_list.append(weather_response['coord']['lon'])
        max_temp_list.append(weather_response['main']['temp_max'])
        humidity_list.append(weather_response['main']['humidity'])
        cloudiness_list.append(weather_response['clouds']['all'])
        windspeed_list.append(weather_response['wind']['speed'])
    except:
        print("City not found: " + city)
        
        
print(len(weather_response))
    
processing Record 1 of Set 1 | rolim de moura
City not found: rolim de moura
processing Record 2 of Set 1 | provideniya
processing Record 3 of Set 1 | tsihombe
City not found: tsihombe
processing Record 4 of Set 1 | yamada
processing Record 5 of Set 1 | pevek
processing Record 6 of Set 1 | chuy
processing Record 7 of Set 1 | iquitos
processing Record 8 of Set 1 | punta arenas
processing Record 9 of Set 1 | taolanaro
City not found: taolanaro
processing Record 10 of Set 1 | hurricane
processing Record 11 of Set 1 | butaritari
processing Record 12 of Set 1 | torit
City not found: torit
processing Record 13 of Set 1 | saint george
processing Record 14 of Set 1 | mayo
processing Record 15 of Set 1 | chokurdakh
processing Record 16 of Set 1 | castro
processing Record 17 of Set 1 | geraldton
processing Record 18 of Set 1 | sambava
processing Record 19 of Set 1 | aklavik
processing Record 20 of Set 1 | ocara
processing Record 21 of Set 1 | guantanamo
processing Record 22 of Set 1 | codrington
processing Record 23 of Set 1 | artyom
processing Record 24 of Set 1 | rikitea
processing Record 25 of Set 1 | safaqis
City not found: safaqis
processing Record 26 of Set 1 | nishihara
processing Record 27 of Set 1 | mogadouro
processing Record 28 of Set 1 | luoyang
processing Record 29 of Set 1 | tuktoyaktuk
processing Record 30 of Set 1 | mataura
processing Record 31 of Set 1 | nizwa
processing Record 32 of Set 1 | hovd
processing Record 33 of Set 1 | port alfred
processing Record 34 of Set 1 | salalah
processing Record 35 of Set 1 | yerofey pavlovich
processing Record 36 of Set 1 | lavrentiya
processing Record 37 of Set 1 | verkhnedneprovskiy
processing Record 38 of Set 1 | jinxiang
processing Record 39 of Set 1 | ushuaia
processing Record 40 of Set 1 | hobart
processing Record 41 of Set 1 | margate
processing Record 42 of Set 1 | jamestown
processing Record 43 of Set 1 | new norfolk
processing Record 44 of Set 1 | nome
processing Record 45 of Set 1 | mys shmidta
City not found: mys shmidta
processing Record 46 of Set 1 | kaohsiung
processing Record 47 of Set 1 | asau
City not found: asau
processing Record 48 of Set 1 | kapaa
processing Record 49 of Set 1 | englewood
2
0
50
processing Record 1 of Set 2 | port elizabeth
processing Record 2 of Set 2 | nuuk
processing Record 3 of Set 2 | broome
processing Record 4 of Set 2 | qala
processing Record 5 of Set 2 | deputatskiy
processing Record 6 of Set 2 | yellowknife
processing Record 7 of Set 2 | satitoa
City not found: satitoa
processing Record 8 of Set 2 | bluff
processing Record 9 of Set 2 | arraial do cabo
processing Record 10 of Set 2 | vaini
processing Record 11 of Set 2 | macaboboni
City not found: macaboboni
processing Record 12 of Set 2 | berlevag
processing Record 13 of Set 2 | rosiori
processing Record 14 of Set 2 | saleaula
City not found: saleaula
processing Record 15 of Set 2 | port-cartier
processing Record 16 of Set 2 | ahuimanu
processing Record 17 of Set 2 | valparaiso
processing Record 18 of Set 2 | belushya guba
City not found: belushya guba
processing Record 19 of Set 2 | ponta do sol
processing Record 20 of Set 2 | hermanus
processing Record 21 of Set 2 | buraydah
processing Record 22 of Set 2 | zhoucheng
processing Record 23 of Set 2 | port hawkesbury
processing Record 24 of Set 2 | luderitz
processing Record 25 of Set 2 | mato verde
processing Record 26 of Set 2 | kusa
processing Record 27 of Set 2 | atar
processing Record 28 of Set 2 | poum
processing Record 29 of Set 2 | portland
processing Record 30 of Set 2 | ancud
processing Record 31 of Set 2 | paita
processing Record 32 of Set 2 | xingtai
processing Record 33 of Set 2 | si satchanalai
processing Record 34 of Set 2 | havelock
processing Record 35 of Set 2 | lazaro cardenas
processing Record 36 of Set 2 | bengkulu
City not found: bengkulu
processing Record 37 of Set 2 | quatre cocos
processing Record 38 of Set 2 | paraiso
processing Record 39 of Set 2 | tura
processing Record 40 of Set 2 | husavik
processing Record 41 of Set 2 | lebu
processing Record 42 of Set 2 | waingapu
processing Record 43 of Set 2 | saint-pierre
processing Record 44 of Set 2 | sentyabrskiy
City not found: sentyabrskiy
processing Record 45 of Set 2 | bredasdorp
processing Record 46 of Set 2 | illoqqortoormiut
City not found: illoqqortoormiut
processing Record 47 of Set 2 | hofn
processing Record 48 of Set 2 | puerto ayora
processing Record 49 of Set 2 | raga
City not found: raga
processing Record 50 of Set 2 | nara
3
0
100
processing Record 1 of Set 3 | chara
processing Record 2 of Set 3 | bilibino
processing Record 3 of Set 3 | busselton
processing Record 4 of Set 3 | kodiak
processing Record 5 of Set 3 | lata
processing Record 6 of Set 3 | krivopolyanye
City not found: krivopolyanye
processing Record 7 of Set 3 | jalingo
processing Record 8 of Set 3 | zhigansk
processing Record 9 of Set 3 | cherskiy
processing Record 10 of Set 3 | khani
processing Record 11 of Set 3 | albany
processing Record 12 of Set 3 | torbay
processing Record 13 of Set 3 | avarua
processing Record 14 of Set 3 | cape town
processing Record 15 of Set 3 | qaanaaq
processing Record 16 of Set 3 | vila velha
processing Record 17 of Set 3 | cidreira
processing Record 18 of Set 3 | yulara
processing Record 19 of Set 3 | rameswaram
processing Record 20 of Set 3 | bambanglipuro
processing Record 21 of Set 3 | guiratinga
processing Record 22 of Set 3 | carnarvon
processing Record 23 of Set 3 | grand river south east
City not found: grand river south east
processing Record 24 of Set 3 | constantine
processing Record 25 of Set 3 | tasiilaq
processing Record 26 of Set 3 | longyearbyen
processing Record 27 of Set 3 | sao joao de pirabas
processing Record 28 of Set 3 | matara
processing Record 29 of Set 3 | hithadhoo
processing Record 30 of Set 3 | atikokan
processing Record 31 of Set 3 | khonuu
City not found: khonuu
processing Record 32 of Set 3 | sibu
processing Record 33 of Set 3 | atuona
processing Record 34 of Set 3 | louisbourg
City not found: louisbourg
processing Record 35 of Set 3 | port hedland
processing Record 36 of Set 3 | renukut
processing Record 37 of Set 3 | vanderhoof
processing Record 38 of Set 3 | yeppoon
processing Record 39 of Set 3 | safwah
City not found: safwah
processing Record 40 of Set 3 | tiznit
processing Record 41 of Set 3 | brae
processing Record 42 of Set 3 | georgetown
processing Record 43 of Set 3 | hilo
processing Record 44 of Set 3 | nizhniy tsasuchey
processing Record 45 of Set 3 | kavieng
processing Record 46 of Set 3 | haljala
processing Record 47 of Set 3 | rawson
processing Record 48 of Set 3 | havre-saint-pierre
processing Record 49 of Set 3 | mezen
processing Record 50 of Set 3 | half moon bay
4
0
150
processing Record 1 of Set 4 | sao filipe
processing Record 2 of Set 4 | mount gambier
processing Record 3 of Set 4 | bethel
processing Record 4 of Set 4 | roswell
processing Record 5 of Set 4 | ilhabela
processing Record 6 of Set 4 | maragogi
processing Record 7 of Set 4 | palabuhanratu
City not found: palabuhanratu
processing Record 8 of Set 4 | amahai
processing Record 9 of Set 4 | mar del plata
processing Record 10 of Set 4 | cayenne
processing Record 11 of Set 4 | gigmoto
processing Record 12 of Set 4 | bengkalis
City not found: bengkalis
processing Record 13 of Set 4 | nanakuli
processing Record 14 of Set 4 | snasa
processing Record 15 of Set 4 | souillac
processing Record 16 of Set 4 | aykhal
processing Record 17 of Set 4 | ahipara
processing Record 18 of Set 4 | kushima
processing Record 19 of Set 4 | san patricio
processing Record 20 of Set 4 | cabo san lucas
processing Record 21 of Set 4 | makungu
processing Record 22 of Set 4 | port lincoln
processing Record 23 of Set 4 | hamilton
processing Record 24 of Set 4 | saint-philippe
processing Record 25 of Set 4 | attawapiskat
City not found: attawapiskat
processing Record 26 of Set 4 | mahajanga
processing Record 27 of Set 4 | dingle
processing Record 28 of Set 4 | sangar
processing Record 29 of Set 4 | sao felix do xingu
processing Record 30 of Set 4 | nouadhibou
processing Record 31 of Set 4 | kirakira
processing Record 32 of Set 4 | urumqi
City not found: urumqi
processing Record 33 of Set 4 | ituni
City not found: ituni
processing Record 34 of Set 4 | airai
processing Record 35 of Set 4 | esperance
processing Record 36 of Set 4 | jacqueville
processing Record 37 of Set 4 | teya
processing Record 38 of Set 4 | bilma
processing Record 39 of Set 4 | bulgan
processing Record 40 of Set 4 | tual
processing Record 41 of Set 4 | nichinan
processing Record 42 of Set 4 | vallenar
processing Record 43 of Set 4 | thompson
processing Record 44 of Set 4 | donduseni
processing Record 45 of Set 4 | severo-kurilsk
processing Record 46 of Set 4 | narsaq
processing Record 47 of Set 4 | elizabethton
processing Record 48 of Set 4 | malakal
City not found: malakal
processing Record 49 of Set 4 | laguna
processing Record 50 of Set 4 | arawa
5
0
200
processing Record 1 of Set 5 | sechura
processing Record 2 of Set 5 | coahuayana
processing Record 3 of Set 5 | klaksvik
processing Record 4 of Set 5 | nikolskoye
processing Record 5 of Set 5 | creel
processing Record 6 of Set 5 | dawei
processing Record 7 of Set 5 | lovozero
processing Record 8 of Set 5 | norman wells
processing Record 9 of Set 5 | mehamn
processing Record 10 of Set 5 | flin flon
processing Record 11 of Set 5 | ilulissat
processing Record 12 of Set 5 | samusu
City not found: samusu
processing Record 13 of Set 5 | katsuura
processing Record 14 of Set 5 | ust-koksa
processing Record 15 of Set 5 | kalianget
processing Record 16 of Set 5 | plettenberg bay
processing Record 17 of Set 5 | la orilla
processing Record 18 of Set 5 | te anau
processing Record 19 of Set 5 | pangody
processing Record 20 of Set 5 | okhotsk
processing Record 21 of Set 5 | hargeysa
processing Record 22 of Set 5 | moses lake
processing Record 23 of Set 5 | kaitangata
processing Record 24 of Set 5 | pisco
processing Record 25 of Set 5 | gallipoli
processing Record 26 of Set 5 | tall kayf
processing Record 27 of Set 5 | killybegs
processing Record 28 of Set 5 | coihaique
processing Record 29 of Set 5 | ngorongoro
processing Record 30 of Set 5 | belmonte
processing Record 31 of Set 5 | leningradskiy
processing Record 32 of Set 5 | kavaratti
processing Record 33 of Set 5 | isangel
processing Record 34 of Set 5 | mahebourg
processing Record 35 of Set 5 | manta
processing Record 36 of Set 5 | hualmay
processing Record 37 of Set 5 | faya
processing Record 38 of Set 5 | east london
processing Record 39 of Set 5 | leo
processing Record 40 of Set 5 | comodoro rivadavia
processing Record 41 of Set 5 | shitanjing
processing Record 42 of Set 5 | iqaluit
processing Record 43 of Set 5 | upernavik
processing Record 44 of Set 5 | floro
processing Record 45 of Set 5 | barentsburg
City not found: barentsburg
processing Record 46 of Set 5 | cap malheureux
processing Record 47 of Set 5 | awbari
processing Record 48 of Set 5 | narathiwat
processing Record 49 of Set 5 | tsuruga
processing Record 50 of Set 5 | huarmey
6
0
250
processing Record 1 of Set 6 | yanan
City not found: yanan
processing Record 2 of Set 6 | hami
processing Record 3 of Set 6 | petropavlovsk-kamchatskiy
processing Record 4 of Set 6 | lasa
processing Record 5 of Set 6 | fort nelson
processing Record 6 of Set 6 | tilichiki
processing Record 7 of Set 6 | yuli
processing Record 8 of Set 6 | altay
processing Record 9 of Set 6 | wolkersdorf
processing Record 10 of Set 6 | samarai
processing Record 11 of Set 6 | riohacha
processing Record 12 of Set 6 | sao joao da barra
processing Record 13 of Set 6 | labytnangi
processing Record 14 of Set 6 | chumikan
processing Record 15 of Set 6 | komsomolskiy
processing Record 16 of Set 6 | dikson
processing Record 17 of Set 6 | soyo
processing Record 18 of Set 6 | mareeba
processing Record 19 of Set 6 | baturaja
processing Record 20 of Set 6 | innisfail
processing Record 21 of Set 6 | chato
processing Record 22 of Set 6 | waipawa
processing Record 23 of Set 6 | bereda
processing Record 24 of Set 6 | bathsheba
processing Record 25 of Set 6 | macau
processing Record 26 of Set 6 | constitucion
processing Record 27 of Set 6 | manzanillo
processing Record 28 of Set 6 | yurginskoye
processing Record 29 of Set 6 | avera
processing Record 30 of Set 6 | oda
processing Record 31 of Set 6 | amderma
City not found: amderma
processing Record 32 of Set 6 | marcona
City not found: marcona
processing Record 33 of Set 6 | khatanga
processing Record 34 of Set 6 | chicama
processing Record 35 of Set 6 | clyde river
processing Record 36 of Set 6 | black forest
processing Record 37 of Set 6 | sangareddi
processing Record 38 of Set 6 | pontianak
processing Record 39 of Set 6 | pangai
processing Record 40 of Set 6 | the valley
processing Record 41 of Set 6 | namibe
processing Record 42 of Set 6 | necochea
processing Record 43 of Set 6 | puerto carreno
processing Record 44 of Set 6 | labuhan
processing Record 45 of Set 6 | barrow
processing Record 46 of Set 6 | tigil
processing Record 47 of Set 6 | phra phutthabat
processing Record 48 of Set 6 | tessalit
processing Record 49 of Set 6 | sao joao da ponte
processing Record 50 of Set 6 | leh
7
0
300
processing Record 1 of Set 7 | megion
processing Record 2 of Set 7 | macenta
processing Record 3 of Set 7 | viedma
processing Record 4 of Set 7 | kahului
processing Record 5 of Set 7 | matagami
processing Record 6 of Set 7 | udachnyy
processing Record 7 of Set 7 | abu zabad
processing Record 8 of Set 7 | kolda
processing Record 9 of Set 7 | sivas
processing Record 10 of Set 7 | mokhos
processing Record 11 of Set 7 | aborlan
processing Record 12 of Set 7 | nizhneyansk
City not found: nizhneyansk
processing Record 13 of Set 7 | beloha
processing Record 14 of Set 7 | ribeira grande
processing Record 15 of Set 7 | hasaki
processing Record 16 of Set 7 | vestmannaeyjar
processing Record 17 of Set 7 | cam pha
City not found: cam pha
processing Record 18 of Set 7 | bambous virieux
processing Record 19 of Set 7 | hihifo
City not found: hihifo
processing Record 20 of Set 7 | tiksi
processing Record 21 of Set 7 | chany
processing Record 22 of Set 7 | lolua
City not found: lolua
processing Record 23 of Set 7 | grindavik
processing Record 24 of Set 7 | boyolangu
processing Record 25 of Set 7 | evenskjaer
City not found: evenskjaer
processing Record 26 of Set 7 | bandarbeyla
processing Record 27 of Set 7 | rungata
City not found: rungata
processing Record 28 of Set 7 | naze
processing Record 29 of Set 7 | krishnarajpet
processing Record 30 of Set 7 | pemangkat
City not found: pemangkat
processing Record 31 of Set 7 | lagoa
processing Record 32 of Set 7 | birjand
processing Record 33 of Set 7 | wazzan
City not found: wazzan
processing Record 34 of Set 7 | port hardy
processing Record 35 of Set 7 | adrar
processing Record 36 of Set 7 | belyy yar
processing Record 37 of Set 7 | warrnambool
processing Record 38 of Set 7 | veraval
processing Record 39 of Set 7 | nemuro
processing Record 40 of Set 7 | gobabis
processing Record 41 of Set 7 | bokovskaya
processing Record 42 of Set 7 | fortuna
processing Record 43 of Set 7 | timaru
processing Record 44 of Set 7 | umzimvubu
City not found: umzimvubu
processing Record 45 of Set 7 | magdagachi
processing Record 46 of Set 7 | saskylakh
processing Record 47 of Set 7 | port blair
processing Record 48 of Set 7 | dicabisagan
processing Record 49 of Set 7 | talnakh
processing Record 50 of Set 7 | villaviciosa
8
0
350
processing Record 1 of Set 8 | xai-xai
processing Record 2 of Set 8 | sitka
processing Record 3 of Set 8 | sur
processing Record 4 of Set 8 | cururupu
processing Record 5 of Set 8 | tuatapere
processing Record 6 of Set 8 | galveston
processing Record 7 of Set 8 | deniliquin
processing Record 8 of Set 8 | tucurui
processing Record 9 of Set 8 | mount isa
processing Record 10 of Set 8 | san cristobal
processing Record 11 of Set 8 | chagda
City not found: chagda
processing Record 12 of Set 8 | touros
processing Record 13 of Set 8 | ambilobe
processing Record 14 of Set 8 | inhambane
processing Record 15 of Set 8 | tiarei
processing Record 16 of Set 8 | hambantota
processing Record 17 of Set 8 | riberalta
processing Record 18 of Set 8 | kaduqli
processing Record 19 of Set 8 | solnechnyy
processing Record 20 of Set 8 | drumheller
processing Record 21 of Set 8 | erenhot
processing Record 22 of Set 8 | tomino
processing Record 23 of Set 8 | mikkeli
processing Record 24 of Set 8 | novyy karachay
processing Record 25 of Set 8 | bassila
processing Record 26 of Set 8 | ilinskiy
processing Record 27 of Set 8 | wakkanai
processing Record 28 of Set 8 | presidencia roque saenz pena
processing Record 29 of Set 8 | antalaha
processing Record 30 of Set 8 | axim
processing Record 31 of Set 8 | alice springs
processing Record 32 of Set 8 | zafra
processing Record 33 of Set 8 | makat
processing Record 34 of Set 8 | saldanha
processing Record 35 of Set 8 | kazalinsk
City not found: kazalinsk
processing Record 36 of Set 8 | pala
processing Record 37 of Set 8 | sorland
processing Record 38 of Set 8 | kathmandu
processing Record 39 of Set 8 | wewak
processing Record 40 of Set 8 | vestmanna
processing Record 41 of Set 8 | dabakala
processing Record 42 of Set 8 | qaqortoq
processing Record 43 of Set 8 | iwanai
processing Record 44 of Set 8 | huacho
processing Record 45 of Set 8 | south lake tahoe
processing Record 46 of Set 8 | faanui
processing Record 47 of Set 8 | anloga
processing Record 48 of Set 8 | arica
processing Record 49 of Set 8 | andenes
City not found: andenes
processing Record 50 of Set 8 | guanare
9
0
400
processing Record 1 of Set 9 | tondano
processing Record 2 of Set 9 | smithers
processing Record 3 of Set 9 | barahona
processing Record 4 of Set 9 | newnan
processing Record 5 of Set 9 | tivoli
processing Record 6 of Set 9 | helong
processing Record 7 of Set 9 | vila franca do campo
processing Record 8 of Set 9 | corinto
processing Record 9 of Set 9 | seydisehir
processing Record 10 of Set 9 | bernardino de campos
processing Record 11 of Set 9 | pecos
processing Record 12 of Set 9 | grand centre
City not found: grand centre
processing Record 13 of Set 9 | raub
processing Record 14 of Set 9 | kiruna
processing Record 15 of Set 9 | goderich
processing Record 16 of Set 9 | waspan
City not found: waspan
processing Record 17 of Set 9 | mentana
processing Record 18 of Set 9 | gudivada
processing Record 19 of Set 9 | harper
processing Record 20 of Set 9 | victoria
processing Record 21 of Set 9 | westport
processing Record 22 of Set 9 | balykshi
City not found: balykshi
processing Record 23 of Set 9 | awjilah
processing Record 24 of Set 9 | olavarria
processing Record 25 of Set 9 | riverton
processing Record 26 of Set 9 | vilhena
processing Record 27 of Set 9 | semey
processing Record 28 of Set 9 | palana
processing Record 29 of Set 9 | tongliao
processing Record 30 of Set 9 | la ronge
processing Record 31 of Set 9 | iquique
processing Record 32 of Set 9 | grand gaube
processing Record 33 of Set 9 | pontes e lacerda
processing Record 34 of Set 9 | svetlogorsk
processing Record 35 of Set 9 | collie
processing Record 36 of Set 9 | baruun-urt
processing Record 37 of Set 9 | yantal
processing Record 38 of Set 9 | pangnirtung
processing Record 39 of Set 9 | douentza
processing Record 40 of Set 9 | monrovia
processing Record 41 of Set 9 | ndele
City not found: ndele
processing Record 42 of Set 9 | warqla
City not found: warqla
processing Record 43 of Set 9 | braslav
City not found: braslav
processing Record 44 of Set 9 | astoria
processing Record 45 of Set 9 | luena
processing Record 46 of Set 9 | roma
processing Record 47 of Set 9 | dayong
processing Record 48 of Set 9 | byron bay
processing Record 49 of Set 9 | sun valley
processing Record 50 of Set 9 | shingu
10
0
450
processing Record 1 of Set 10 | taitung
processing Record 2 of Set 10 | phan thiet
processing Record 3 of Set 10 | tombouctou
processing Record 4 of Set 10 | mackay
processing Record 5 of Set 10 | marzuq
processing Record 6 of Set 10 | barra do garcas
processing Record 7 of Set 10 | yialos
City not found: yialos
processing Record 8 of Set 10 | henties bay
processing Record 9 of Set 10 | san rafael
processing Record 10 of Set 10 | praia
processing Record 11 of Set 10 | sassandra
processing Record 12 of Set 10 | manaure
processing Record 13 of Set 10 | santo estevao
processing Record 14 of Set 10 | myitkyina
processing Record 15 of Set 10 | balaghat
processing Record 16 of Set 10 | verkhnyaya inta
processing Record 17 of Set 10 | stornoway
City not found: stornoway
processing Record 18 of Set 10 | dossor
processing Record 19 of Set 10 | piracuruca
processing Record 20 of Set 10 | rayevskiy
processing Record 21 of Set 10 | mehkar
processing Record 22 of Set 10 | amurrio
processing Record 23 of Set 10 | ulladulla
processing Record 24 of Set 10 | kanniyakumari
processing Record 25 of Set 10 | zarubino
processing Record 26 of Set 10 | santa luzia
processing Record 27 of Set 10 | kindu
processing Record 28 of Set 10 | korla
City not found: korla
processing Record 29 of Set 10 | marsh harbour
processing Record 30 of Set 10 | barentu
processing Record 31 of Set 10 | buon me thuot
City not found: buon me thuot
processing Record 32 of Set 10 | tumannyy
City not found: tumannyy
processing Record 33 of Set 10 | cedar city
processing Record 34 of Set 10 | springdale
processing Record 35 of Set 10 | hellvik
processing Record 36 of Set 10 | illela
processing Record 37 of Set 10 | jiangyou
processing Record 38 of Set 10 | monywa
processing Record 39 of Set 10 | maroantsetra
processing Record 40 of Set 10 | grants
processing Record 41 of Set 10 | methoni
processing Record 42 of Set 10 | general roca
processing Record 43 of Set 10 | ongandjera
processing Record 44 of Set 10 | mariental
processing Record 45 of Set 10 | lake cowichan
processing Record 46 of Set 10 | anadyr
processing Record 47 of Set 10 | karratha
processing Record 48 of Set 10 | paamiut
processing Record 49 of Set 10 | falam
processing Record 50 of Set 10 | kaeo
11
0
500
processing Record 1 of Set 11 | ofunato
processing Record 2 of Set 11 | maningrida
processing Record 3 of Set 11 | muros
processing Record 4 of Set 11 | qandala
processing Record 5 of Set 11 | bonavista
processing Record 6 of Set 11 | beyneu
processing Record 7 of Set 11 | melnikovo
processing Record 8 of Set 11 | muhos
processing Record 9 of Set 11 | noyabrsk
processing Record 10 of Set 11 | hauterive
processing Record 11 of Set 11 | chifeng
processing Record 12 of Set 11 | srednekolymsk
processing Record 13 of Set 11 | alofi
processing Record 14 of Set 11 | alyangula
processing Record 15 of Set 11 | tlalcilalcalpan
City not found: tlalcilalcalpan
processing Record 16 of Set 11 | sisimiut
processing Record 17 of Set 11 | mangai
processing Record 18 of Set 11 | vieques
processing Record 19 of Set 11 | puerto escondido
processing Record 20 of Set 11 | bhag
processing Record 21 of Set 11 | kieta
processing Record 22 of Set 11 | toftir
City not found: toftir
processing Record 23 of Set 11 | thinadhoo
processing Record 24 of Set 11 | bay city
processing Record 25 of Set 11 | kungurtug
processing Record 26 of Set 11 | tumut
processing Record 27 of Set 11 | caravelas
processing Record 28 of Set 11 | ryde
processing Record 29 of Set 11 | murchison
processing Record 30 of Set 11 | madaoua
processing Record 31 of Set 11 | den helder
processing Record 32 of Set 11 | sabratah
processing Record 33 of Set 11 | neftekumsk
processing Record 34 of Set 11 | ponta delgada
processing Record 35 of Set 11 | kopavogur
processing Record 36 of Set 11 | maridi
City not found: maridi
processing Record 37 of Set 11 | rocha
processing Record 38 of Set 11 | jumla
processing Record 39 of Set 11 | neiafu
processing Record 40 of Set 11 | miranda
processing Record 41 of Set 11 | zheleznodorozhnyy
processing Record 42 of Set 11 | lekhovon
City not found: lekhovon
processing Record 43 of Set 11 | mount darwin
processing Record 44 of Set 11 | kosh-agach
processing Record 45 of Set 11 | lidkoping
processing Record 46 of Set 11 | namatanai
processing Record 47 of Set 11 | bocaranga
City not found: bocaranga
processing Record 48 of Set 11 | jacareacanga
processing Record 49 of Set 11 | vardo
processing Record 50 of Set 11 | meulaboh
12
0
550
processing Record 1 of Set 12 | alibag
processing Record 2 of Set 12 | ukiah
processing Record 3 of Set 12 | ulaangom
processing Record 4 of Set 12 | yirol
City not found: yirol
processing Record 5 of Set 12 | broken hill
processing Record 6 of Set 12 | pueblo nuevo
processing Record 7 of Set 12 | novaya ladoga
processing Record 8 of Set 12 | les cayes
processing Record 9 of Set 12 | muscat
processing Record 10 of Set 12 | moree
processing Record 11 of Set 12 | uruzgan
processing Record 12 of Set 12 | fairbanks
processing Record 13 of Set 12 | camacha
processing Record 14 of Set 12 | olinda
processing Record 15 of Set 12 | college
processing Record 16 of Set 12 | kerrville
processing Record 17 of Set 12 | guerrero negro
processing Record 18 of Set 12 | catuday
processing Record 19 of Set 12 | ruatoria
City not found: ruatoria
processing Record 20 of Set 12 | flinders
processing Record 21 of Set 12 | sagar
processing Record 22 of Set 12 | shatalovo
processing Record 23 of Set 12 | bacolod
processing Record 24 of Set 12 | portadown
processing Record 25 of Set 12 | san quintin
processing Record 26 of Set 12 | pampa
processing Record 27 of Set 12 | washington
processing Record 28 of Set 12 | utiroa
City not found: utiroa
processing Record 29 of Set 12 | belaya gora
processing Record 30 of Set 12 | khandyga
processing Record 31 of Set 12 | nago
processing Record 32 of Set 12 | lethem
processing Record 33 of Set 12 | karasjok
processing Record 34 of Set 12 | reconquista
processing Record 35 of Set 12 | aripuana
processing Record 36 of Set 12 | buin
processing Record 37 of Set 12 | teknaf
processing Record 38 of Set 12 | baleshwar
processing Record 39 of Set 12 | presidente epitacio
processing Record 40 of Set 12 | yashan
processing Record 41 of Set 12 | zelenoborskiy
processing Record 42 of Set 12 | koboldo
City not found: koboldo
processing Record 43 of Set 12 | cabatuan
processing Record 44 of Set 12 | nhlangano
processing Record 45 of Set 12 | gat
processing Record 46 of Set 12 | madang
processing Record 47 of Set 12 | pirapora
processing Record 48 of Set 12 | tucuma
City not found: tucuma
processing Record 49 of Set 12 | fare
processing Record 50 of Set 12 | stefanesti
13
0
600
processing Record 1 of Set 13 | ullapool
processing Record 2 of Set 13 | rundu
processing Record 3 of Set 13 | konevo
processing Record 4 of Set 13 | copiapo
processing Record 5 of Set 13 | basco
processing Record 6 of Set 13 | maues
processing Record 7 of Set 13 | baykit
processing Record 8 of Set 13 | ksenyevka
City not found: ksenyevka
processing Record 9 of Set 13 | pingyin
11
In [11]:
print(len(city_list))
print(len(lat_list))
print(len(lng_list))
print(len(max_temp_list))
print(len(humidity_list))
print(len(cloudiness_list))
print(len(windspeed_list))
543
543
543
543
543
543
543
In [12]:
weather_dict = {"city":city_list,
                "lat":lat_list,
                "lng":lng_list,
                "max_temp":max_temp_list,
                "humidity":humidity_list,
                "cloudiness":cloudiness_list,
                "windspeed":windspeed_list
}

Convert Raw Data to DataFrame

  • Export the city data into a .csv.
  • Display the DataFrame
In [13]:
weather_df = pd.DataFrame(weather_dict)
weather_df.head()
Out[13]:
city lat lng max_temp humidity cloudiness windspeed
0 Provideniya 64.42 -173.23 2.49 68 63 2.56
1 Yamada 36.58 137.08 26.11 38 0 2.10
2 Pevek 69.70 170.27 -2.31 69 95 1.23
3 Chuy -33.69 -53.46 16.09 80 0 6.81
4 Iquitos -3.75 -73.25 27.00 88 0 1.50
In [19]:
weather_df.to_html("table.html")

Plotting the Data

  • Use proper labeling of the plots using plot titles (including date of analysis) and axes labels.
  • Save the plotted figures as .pngs.

Latitude vs. Temperature Plot

In [14]:
plt.scatter(weather_df['lat'], weather_df['max_temp'], edgecolor="black", linewidths=1, marker="o",
           alpha=0.8, label="Cities")
plt.xlabel("Latitude")
plt.ylabel("Max Temperature (F)")
plt.title("City Latitude vs. Max Temperature (04/03/2019)")
plt.savefig("Max_temp.png")

Latitude vs. Humidity Plot

In [15]:
plt.scatter(weather_df['lat'], weather_df['humidity'], edgecolor="black", linewidths=1, marker="o",
           alpha=0.8, label="Cities")
plt.xlabel("Latitude")
plt.ylabel("Humidity (%)")
plt.title("City Latitude vs. Humidity (04/03/2019)")
plt.savefig("Humidity.png")

Latitude vs. Cloudiness Plot

In [16]:
plt.scatter(weather_df['lat'], weather_df['cloudiness'], edgecolor="black", linewidths=1, marker="o",
           alpha=0.8, label="Cities")
plt.xlabel("Latitude")
plt.ylabel("Cloudiness (%)")
plt.title("City Latitude vs. Cloudiness (04/03/2019)")
plt.savefig("Cloudiness.png")

Latitude vs. Wind Speed Plot

In [17]:
plt.scatter(weather_df['lat'], weather_df['windspeed'], edgecolor="black", linewidths=1, marker="o",
           alpha=0.8, label="Cities")
plt.xlabel("Latitude")
plt.ylabel("Wind Speed (mph)")
plt.title("City Latitude vs. Wind Speed (04/03/2019)")
plt.savefig("Wind_Speed.png")
In [ ]: