Planning a vacation to Honolulu, Hawaii! By Python and SQLAlchemy, I will be doing basic climate analysis and data exploration from climate database to plan this vacation.
Used Python and SQLAlchemy ORM queries with provided hawaii.sqlite to reflect tables into a new model and perform analysis of Hawaii climate.
Built a Flask Web app using the served queries that will return JSONified query results from API endpoints.
Climate Analysis using SQLAlchemy and Python
Design a Flask API Web Climate App
Used Python and SQLAlchemy to do basic climate analysis and data exploration of your climate database.
All of the following analysis were completed using SQLAlchemy ORM queries, Pandas, and Matplotlib.
create_engine
to connect to "hawaii.sqlite" databaseUsed SQLAlchemy automap_base()
to reflect your tables into classes and save a reference to those classes called Station
and Measurement
.
Reflected Tables into SQLAlchemy ORM
Designed a query to retrieve the last 12 months of precipitation data.
Selected only the date
and prcp
values.
Loaded the query results into a Pandas DataFrame and set the index to the date column.
Sorted the DataFrame values by date
.
Plotted the results using the DataFrame plot
method.
Defined a function called calc_temps
to calculate the min, avg, and max temperatures for your trip using the matching dates from the previous year (i.e., use "2017-01-01" if your trip start date was "2018-01-01").
Plotted the min, avg, and max temperature from your previous query as a bar chart.
Used the average temperature as the bar height.
Used the peak-to-peak (TMAX-TMIN) value as the y error bar (YERR).
Calculated the rainfall per weather station using the previous year's matching dates.
Calculated the daily normals. Normals are the averages for the min, avg, and max temperatures.
Defined a function called daily_normals
that will calculate the daily normals for a specific date. This date string will be in the format %m-%d
.
Created a list of dates for your trip in the format %m-%d
. Used the daily_normals
function to calculate the normals for each date string and append the results to a list.
Loaded the list of daily normals into a Pandas DataFrame and set the index equal to the date.
Used Pandas to plot an area plot (stacked=False
) for the daily normals.
Below Steps have been done/executed in Hawaii Climate App
/
/api/v1.0/precipitation
date
as the key and prcp
as the value./api/v1.0/stations
/api/v1.0/tobs
/api/v1.0/<start>
and /api/v1.0/<start>/<end>
TMIN
, TAVG
, and TMAX
for all dates greater than and equal to the start date.TMIN
, TAVG
, and TMAX
for dates between the start and end date inclusive.
Fereshteh Aghaei © 2021. All Rights Reserved.