SQLAlchemy Homework - Surfs Up! Climate Analysis
-
Create a new repository for this project called
sqlalchemy-challenge. Do not add this homework to an existing repository. -
Clone the new repository to your computer.
-
Add your Jupyter notebook and
app.pyto this folder. These will be the main scripts to run for analysis. -
Push the above changes to GitHub or GitLab.
Congratulations! You've decided to treat yourself to a long holiday vacation in Honolulu, Hawaii! To help with your trip planning, you need to do some climate analysis on the area. The following outlines what you need to do.
To begin, use Python and SQLAlchemy to do basic climate analysis and data exploration of your climate database. All of the following analysis should be completed using SQLAlchemy ORM queries, Pandas, and Matplotlib.
-
Use the provided starter notebook and hawaii.sqlite files to complete your climate analysis and data exploration.
-
Choose a start date and end date for your trip. Make sure that your vacation range is approximately 3-15 days total.
-
Use SQLAlchemy
create_engineto connect to your sqlite database. -
Use SQLAlchemy
automap_base()to reflect your tables into classes and save a reference to those classes calledStationandMeasurement.
-
Design a query to retrieve the last 12 months of precipitation data.
-
Select only the
dateandprcpvalues. -
Load the query results into a Pandas DataFrame and set the index to the date column.
-
Sort the DataFrame values by
date. -
Plot the results using the DataFrame
plotmethod. -
Use Pandas to print the summary statistics for the precipitation data.
-
Design a query to calculate the total number of stations.
-
Design a query to find the most active stations.
-
List the stations and observation counts in descending order.
-
Which station has the highest number of observations?
-
Hint: You will need to use a function such as
func.min,func.max,func.avg, andfunc.countin your queries.
-
-
Design a query to retrieve the last 12 months of temperature observation data (TOBS).
Now that you have completed your initial analysis, design a Flask API based on the queries that you have just developed.
- Use Flask to create your routes.
-
/-
Home page.
-
List all routes that are available.
-
-
/api/v1.0/precipitation-
Convert the query results to a dictionary using
dateas the key andprcpas the value. -
Return the JSON representation of your dictionary.
-
-
/api/v1.0/stations- Return a JSON list of stations from the dataset.
-
/api/v1.0/tobs-
Query the dates and temperature observations of the most active station for the last year of data.
-
Return a JSON list of temperature observations (TOBS) for the previous year.
-
-
/api/v1.0/<start>and/api/v1.0/<start>/<end>-
Return a JSON list of the minimum temperature, the average temperature, and the max temperature for a given start or start-end range.
-
When given the start only, calculate
TMIN,TAVG, andTMAXfor all dates greater than and equal to the start date. -
When given the start and the end date, calculate the
TMIN,TAVG, andTMAXfor dates between the start and end date inclusive.
-
-
You will need to join the station and measurement tables for some of the queries.
-
Use Flask
jsonifyto convert your API data into a valid JSON response object.
Trilogy Education Services © 2020. All Rights Reserved.


