Skip to content

This project analyzes Weather and Geographical data using Python and APIs by getting data from Geoapify and OpenWeatherMap API.

Notifications You must be signed in to change notification settings

saraparveen26/Python-API---Weather-and-Vacation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

World Weather - Challenge 6 (Python-API)

"What is the weather like as we approach the equator?" This exercise aims to provide information around this topic using Python requests, APIs and JSON traversals. This challenge was created as a requirement for Challenge 6 of Data Analytics Bootcamp at University of Toronto. It has two parts: WeatherPy and VacationPy.

API keys for WeatherAPI and Geoapify were generated and stored in the api_keys.py file which was added to .gigignore to avoid sharing them publicly.

WeatherPy

This deliverable starts by importing dependencies, setup, API key and citipy for the Jupyter Notebook. Then a list of cities is generated by using the citipy library by first defining a range of latitudes and longitudes and then creating a random combination of these two. My initial list contains 623 cities.

As the next requirment, weather data including latitude, longitude, maximum temperature, humidity, cloudiness, wind speed, country and date are retrieved from OpenWeatherMap API for the cities list created in previous step. This led to full data retrieved for 575 cities which was converted into a Pandas DataFrame and exported into a CSV file.

This CSV file is then read to create scatter plots to showcase relationship between Latitude and different weather variables including Maximum Temperature, Humidity, Cloudiness and Wind Speed. All the images for these scatter plots are saved to output_data folder.

Finally, linear regression is computed for various relationships by defining a formula. The original dataframe for cities is split to two: one for the cities in the Northern Hemisphere (with latitude greater than or equal to zero degrees), and second with the cities in Southern Hemisphere (with latitude less than zero degrees). For my dataset, there are 400 cities in Northern Hemishphere and 175 in the Southern Hemisphere.

Linear regression is then plotted including the slope and the regression equation for both Northern and Southern Hemisphere dataframes showing relationship between Latitude and Weather variables. r-values are also displayed for each of these plots. The only strong relationship is displayed between latitude and maximum temperature for cities in the Northern Hemisphere confirming the belief that it gets hotter as you move closer to the equator. All the other variables showed weak to no relationships.

VacationPy

The second deliverable starts by importing dependencies, setup and Geoapify key. Then the CSV created in WeatherPy activity is loaded to read the data.

A map is then created using hvplot to display a point for every city in the dataset. The size of the point is based on the humidity level for each city.

The dataframe is then narrowed down to find my ideal weather conditions. I defined my ideal minimum and maximum temperatures, wind speed, cloudiness, and humidity levels. The dataset is then filtered to retrieve only those cities that fit my ideal weather conditions and any rows with null values are dropped. My ideal cities data comprises of 22 cities.

A new hotels dataframe is then created for my ideal cities to store city, country, coordinates, and humidity data and another blank column is created for hotel names. Using Geoapify API, the first hotel located within 10,000 meters of the coordinates of each ideal vacation city is retrieved and added to the empty Hotel Name column created previously.

As a final step, the ideal cities are then plotted on a map with the size of each city point corresponding to the humidity level in the city. The hover message is updated to include hotel name and country information.

About

This project analyzes Weather and Geographical data using Python and APIs by getting data from Geoapify and OpenWeatherMap API.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published