https://github.com/martachesnova/python-apis
A weather analysis that randomly selects more than 500 cities across the globe, pulls data from the OpenWeatherMap API for each city. Analysis of the weather and perfect vacation spot is viewable on my Jupyter Notebook.
https://github.com/martachesnova/python-apis
api data-analysis python
Last synced: over 1 year ago
JSON representation
A weather analysis that randomly selects more than 500 cities across the globe, pulls data from the OpenWeatherMap API for each city. Analysis of the weather and perfect vacation spot is viewable on my Jupyter Notebook.
- Host: GitHub
- URL: https://github.com/martachesnova/python-apis
- Owner: martachesnova
- Created: 2021-07-21T22:10:28.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-11-02T08:06:56.000Z (over 4 years ago)
- Last Synced: 2025-01-06T10:13:37.511Z (over 1 year ago)
- Topics: api, data-analysis, python
- Language: Jupyter Notebook
- Homepage:
- Size: 2.74 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python-APIs
# What's the Weather Like?
## Background
Using Python requests, APIs, and JSON traversals let's answer a fundamental question: "What's the weather like as we approach the equator?"
Now, you may be thinking: _"Duh. It gets hotter..."_
But, if pressed, how would you **prove** it?

## Part I - Weather
Visualized the weather of 500+ random cities across the world of varying distance from the equator. To accomplish this, I utilized the citipy module, the [OpenWeatherMap API](https://openweathermap.org/api), and a little common sense to create a representative model of weather across world cities.
Created a series of scatter plots to showcase the following relationships:
* Temperature (F) vs. Latitude
* Humidity (%) vs. Latitude
* Cloudiness (%) vs. Latitude
* Wind Speed (mph) vs. Latitude
Then I ran linear regression on each relationship, only this time separating them into Northern Hemisphere (greater than or equal to 0 degrees latitude) and Southern Hemisphere (less than 0 degrees latitude):
* Northern Hemisphere - Temperature (F) vs. Latitude
* Southern Hemisphere - Temperature (F) vs. Latitude
* Northern Hemisphere - Humidity (%) vs. Latitude
* Southern Hemisphere - Humidity (%) vs. Latitude
* Northern Hemisphere - Cloudiness (%) vs. Latitude
* Southern Hemisphere - Cloudiness (%) vs. Latitude
* Northern Hemisphere - Wind Speed (mph) vs. Latitude
* Southern Hemisphere - Wind Speed (mph) vs. Latitude
Interesting to know:
* Every time I run my code, it randomly selects **at least** 500 unique (non-repeat) cities based on latitude and longitude.
* Performs a weather check on each of the cities using a series of successive API calls.
* Includes a print log of each city as it's being processed with the city number and city name.
* Saves a CSV of all retrieved data and a PNG image for each scatter plot.
### Part II - Vacation
Then I decided to work with weather data to plan future vacations. Used jupyter-gmaps and the Google Places API (part of Google Cloud).
(I had trouble displaying the maps, so I ran `jupyter nbextension enable --py gmaps` in my environment.)
* Created a heat map that displays the humidity for every city from the Part I.

* Narrowed down the DataFrame to find my ideal weather condition. Set:
* Range of temperature for my perfect vacation (min and max).
* Wind speed range.
* Cloudiness range.
* Dropped any rows that didn't contain all three conditions. I wanted to be sure the weather was ideal.
* Using Google Places API, I found the first hotel for each city located within 5000 meters of my coordinates.
* Plotted the hotels on top of the humidity heatmap with each pin containing the **Hotel Name**, **City**, and **Country**.
