- This repository contains examples of using API calls from OpenWeather and Google Places and Google Directions
- The data gleaned from these API requests created the following:
- A Weather Database
- A Vacation Search
- A Vacation Itenerary
- To extract data from the OpenWeather API I followed this basic process:
- First generated random latitude and longitude values using the NumPy
random
function - Used the CitiPy library with a for loop to assign a city to those coordinates, populating a new list with the city names.
- Performed an API request to OpenWeather and used the try-except method to add the weather data to a new list.
- Involved parsing the JSON file for the following data:
- Max Temp
- Cloudiness
- Humidity
- Wind Speed
- Current Weather Description
- Country
- Involved parsing the JSON file for the following data:
- First generated random latitude and longitude values using the NumPy
- Finally, converted the list generated by the try-except method to a Pandas DataFrame and exported the DataFrame as a .csv file.
-
Now developing a way to isolate cities that fit a user's preferred temperature range.
-
Overall process included the following:
- Read the WeatherPy_Database.csv as a Pandas DataFrame
- Using the
input()
function to prompt the user to provide minimum and maximum preferred temperatures and storing those values as discrete variables. - Use the
loc
method to isolate the cities that fit the user's criteria and create a new DataFrame. - Check the DataFrame for any empty rows
- Make a copy of the DataFrame and add a "Hotel Name" column
- Iterate through the new DataFrame using
iterrows()
and perform an API request to the Google Nearby Search to locate hotels that fit the parameters. - Use the try-except method to add the hotel names to the "Hotel Name" column in the DataFrame.
- Remove any empty rows by:
- using the
loc
function to isolate any rows without a Hotel - assign those empty rows to NaN using NumPy
nan
function - Drop the rows with NaN using
dropna()
- using the
- Export the DataFrame as a .csv file
- Use
gmaps
to add a map with a marker layer with the following information:- Hotel Name
- City Name
- Country
- Weather Description with Max Temp
-
This deliverable creates a travel itenerary to four cities that meet the user's temperature criteria, creates a map of directions, and a map with markers giving hotel information.
-
Overall process included the following:
- Import the WeatherPy_Vacation.csv file
- Use
gmaps
to create a map with markers holding hotel, city, country, and weather information - Create 4 discrete DataFrames for each of the 4 cities in the trip itenerary.
- Isolate the Latitude and Longitude for each city using
to_numpy()
and indexing. - Use the Google Directions API and
gmaps
to create a map with a directions layer for the itenerary.- Start and End city are the same
- Other 3 cities are considered
waypoints
- Use the
concat()
function to concatenate the 4 city DataFrames into one itenerary DataFrame. - Create a new map with markers for only the cities in the itenerary DataFrame.
- This challenge culminates in creating a vacation itenerary based on a user's temperature prefernces.
- To do so, it must work in the following logical order:
- Obtain latitude and longitude coordinates for cities.
- Assign cities to those coordinates.
- Request weather information for those cities and store in a .csv databse.
- Obtain temperature preferences from the user and create, find hotels in those cities based on those preferences.
- Finally create the itenerary after all the necessary data is collected and visualized.
- Understanding the end product and using proper psuedocoding creates smooth development process.