In this section, Have used Python and SQLAlchemy to do a basic climate analysis and data exploration of climate database. Specifically, have used SQLAlchemy ORM queries, Pandas, and Matplotlib.
After completting the initial analysis, have designed a Flask API based on the queries that was just developed. To do so, used the Flask to create routes.
A long holiday vacation in Honolulu, Hawaii. To help with trip planning, have decided to do a climate analysis about the area. The following sections outline the steps that are considered to take to accomplish this task. Task was broken down into the following tasks:
Part 1: Analyze and Explore the Climate Data Part 2: Designning Climate App
In this section, have used Python and SQLAlchemy to do a basic climate analysis and data exploration of climate database.
Specifically, used SQLAlchemy ORM queries, Pandas, and Matplotlib.
To do so, complete the following steps:
Used the SQLAlchemy "create_engine()" function to connect to SQLite database. Used the SQLAlchemy "automap_base()" function to reflect tables into classes, and then saved references to the classes named station and measurement.
Linked Python to the database by creating a SQLAlchemy session. closed session at the end of the notebook.
Performed a precipitation analysis and then a station analysis by completing the steps in the following two subsections.
- Found the most recent date in the dataset.
- By Using that date, got the previous 12 months of precipitation data by querying the previous 12 months of data.
- Loaded the query results into a Pandas DataFrame. Explicitly set the column names.
- Sorted the DataFrame values by "date".
- Plotted the results by using the DataFrame plot method.
- Used Pandas to print the summary statistics for the precipitation data.
- Designed a query to calculate the total number of stations in the dataset.
- Designed a query to find the most-active stations (that is, the stations that have the most rows). To do so, completed the following steps:
- Listed the stations and observation counts in descending order.
to Answer the following question: which station id has the greatest number of observations? Designed a query that calculates the lowest, highest, and average temperatures that filters on the most-active station id found in the previous query.
- Designed a query to get the previous 12 months of temperature observation (TOBS) data. To do so, complete the following steps:
- Filtered by the station that has the greatest number of observations.
- Query the previous 12 months of TOBS data for that station.
- Plotted the results as a histogram with bins=12, as the following image shows:
- depictted the histogram.
- Closed your session.
After completting the initial analysis, have designed a Flask API based on the queries that was just developed. To do so, used the Flask to create routes as follows:
- /
. Startted at the homepage. . Listed all the available routes.
- /api/v1.0/precipitation
. Converted the query results from precipitation analysis (i.e. retrieve only the last 12 months of data) to a dictionary using date as the key and prcp as the value. . Returned the JSON representation of dictionary.
- /api/v1.0/stations
. Returned 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 previous year of data. . Returned a JSON list of temperature observations for the previous year.
- /api/v1.0/ and /api/v1.0//
. Returned a JSON list of the minimum temperature, the average temperature, and the maximum temperature for a specified start or start-end range. . For a specified start, calculated TMIN, TAVG, and TMAX for all the dates greater than or equal to the start date. . For a specified start date and end date, calculated TMIN, TAVG, and TMAX for the dates from the start date to the end date, inclusive.
. Joinned the station and measurement tables for some of the queries. . Used the Flask jsonify function to convert API data to a valid JSON response object.
. Created a new repository for this project called "sqlalchemy-challenge", Cloned the new repository(remote) to local by terminal.
. Inside my local Git repository, created a folder for "SurfsUp"
. Added Jupyter notebook "climate_starter.ipynb" and python script for app "app.py" to this folder.
. This is the main script to run this analysis.
. A Resources folder that contains the CSV files(Raw Data) and "hawaii.sqlite" i have used.
. Pushed these changes to GitHub profile by bash terminal.