UNC_data_bootcamp_module_10
Congratulations! You've decided to treat yourself to a long holiday vacation in Honolulu, Hawaii. To help with your trip planning, you decide to do a climate analysis about the area. The following sections outline the steps that you need to take to accomplish this task.
from the UNC Bootcamp instructions for this challenge
This challenge consists of two parts. For Part-1 we'll use resource file data to create a Jupyter notebook to calculate the precipitation and temperature in Hawaii within a given date range. Then for Part-2 we will use the data from that Jupyter notebook to create a Flask API to output those statistics as JSON style webpages.
For this part, we are using Python and SQLAlchemy to do a basic climate analysis in a Jupyter notebook called climate_analysis_SDT.ipynb using SQLAlchemy (ORM queries), Pandas, and Matplotlib. We are using the provided starter code files (climate_starter.ipynb and hawaii.sqlite) along with the Resource folder files to analyze this data. When finished, we will use this data to perform a Precipitation analysis and as well as a Station analysis in two subsections and plot our findings on a chart. Chart data will be provided for each subsection.
This analysis is to be performed in the following steps per the instructions:
-
Find the most recent date in the dataset.
-
Using that date, get the previous 12 months of precipitation data by querying the previous 12 months of data.
-
Select only the "date" and "prcp" values.
-
Load the query results into a Pandas DataFrame. Explicitly set the column names.
-
Sort the DataFrame values by "date".
-
Plot the results by using the DataFrame plot method:
Hawaii Precipitation Chart
- Use Pandas to print the summary statistics for the precipitation data.
This analysis is to be performed in the following steps per the instructions:
-
Design a query to calculate the total number of stations in the dataset.
-
Design a query to find the most-active stations, meaning:
- List the stations and observation counts in descending order.
- Determine which station id has the greatest number of observations.
-
Design a query that calculates the lowest, highest, and average temperatures that filters on the most-active station id found in the previous query.
-
Design a query to get the previous 12 months of Temperature Observation (TOBS) data as follows:
- Filter by the station that has the greatest number of observations.
- Query the previous 12 months of TOBS data for that station.
- Plot the results as a histogram with bins=12:
12 Months of Temperature Observation Chart
For this part, we will design a Flask API called app_SDT.py based on the queries created with Jupyter notebook.
Per the challenge instructions, we are creating the following routes as well as specific parameters:
- Home Route
/
- Start at the homepage.
- List all the available routes.
- Precipitation Route
/api/v1.0/precipitation
- Convert the query results from your precipitation analysis (only the last 12 months of data) to a dictionary using date as the key and prcp as the value.
- Return the JSON representation of your dictionary.
- Stations Route
/api/v1.0/stations
- Return a JSON list of stations from the dataset.
- Temperature Observation Route
/api/v1.0/tobs
- Query the dates and temperature observations of the most-active station for the previous year of data.
- Return a JSON list of temperature observations for the previous year.
- Start date OR Start & End date Route
/api/v1.0/<start> and /api/v1.0/<start>/<end>
- Return a JSON list of the minimum, average, and maximum temperature for a specified start or start-end range.
- For a specified start, calculate TMIN, TAVG, and TMAX for all the dates greater than or equal to the start date.
- For a specified start date and end date, calculate TMIN, TAVG, and TMAX for the dates from the start date to the end date, inclusive.
Module 10 Instructions
starter_code:
- app.py
- climate_starter.ipynb
Resources folder:
- hawaii_measurements.csv
- hawaii_stations.csv
- hawaii.sqlite
Special Thanks:
- Jamie Miller
- Mounika Mamindla
- Lisa Shemanciik
- pandas documentation
- matplotlib documentation
- SQLAlchemy documentation
- Flask documentation
- YouTube (various tutorials)