Giter VIP home page Giter VIP logo

sqlalchemy's Introduction

SQLAlchemy Homework - Surfs Up!

Before You Begin

  1. Create a new repository for this project called sqlalchemy-challenge. Do not add this homework to an existing repository.

  2. Clone the new repository to your computer.

  3. Add your Jupyter notebook and app.py to this folder. These will be the main scripts to run for analysis.

  4. Push the above changes to GitHub or GitLab.

surfs-up.png

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.

Step 1 - Climate Analysis and Exploration

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_engine to connect to your sqlite database.

  • Use SQLAlchemy automap_base() to reflect your tables into classes and save a reference to those classes called Station and Measurement.

Precipitation Analysis

  • Design a query to retrieve the last 12 months of precipitation data.

  • Select only the date and prcp values.

  • 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 plot method.

    precipitation

  • Use Pandas to print the summary statistics for the precipitation data.

Station Analysis

  • 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 may need to use functions such as func.min, func.max, func.avg, and func.count in your queries.

  • Design a query to retrieve the last 12 months of temperature observation data (tobs).

    • Filter by the station with the highest number of observations.

    • Plot the results as a histogram with bins=12.

      station-histogram


Step 2 - Climate App

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.

Routes

  • /

    • Home page.

    • List all routes that are available.

  • /api/v1.0/precipitation

    • Convert the query results to a Dictionary using date as the key and prcp as 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 for the dates and temperature observations from a year from the last data point.
    • 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, and TMAX for all dates greater than and equal to the start date.

    • When given the start and the end date, calculate the TMIN, TAVG, and TMAX for dates between the start and end date inclusive.

Hints

  • You will need to join the station and measurement tables for some of the analysis queries.

  • Use Flask jsonify to convert your API data into a valid JSON response object.


Optional: Other Recommended Analyses

  • The following are optional challenge queries. These are highly recommended to attempt, but not required for the homework.

Temperature Analysis I

  • Hawaii is reputed to enjoy mild weather all year. Is there a meaningful difference between the temperature in, for example, June and December?

  • You may either use SQLAlchemy or pandas's read_csv() to perform this portion.

  • Identify the average temperature in June at all stations across all available years in the dataset. Do the same for December temperature.

  • Use the t-test to determine whether the difference in the means, if any, is statistically significant. Will you use a paired t-test, or an unpaired t-test? Why?

Temperature Analysis II

  • The starter notebook contains a function called calc_temps that will accept a start date and end date in the format %Y-%m-%d and return the minimum, average, and maximum temperatures for that range of dates.

  • Use the calc_temps function 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").

  • Plot the min, avg, and max temperature from your previous query as a bar chart.

    • Use the average temperature as the bar height.

    • Use the peak-to-peak (tmax-tmin) value as the y error bar (yerr).

      temperature

Daily Rainfall Average

  • Calculate the rainfall per weather station using the previous year's matching dates.

  • Calculate the daily normals. Normals are the averages for the min, avg, and max temperatures.

  • You are provided with 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. Be sure to use all historic tobs that match that date string.

  • Create a list of dates for your trip in the format %m-%d. Use the daily_normals function to calculate the normals for each date string and append the results to a list.

  • Load the list of daily normals into a Pandas DataFrame and set the index equal to the date.

  • Use Pandas to plot an area plot (stacked=False) for the daily normals.

    daily-normals

Copyright

Trilogy Education Services © 2019. All Rights Reserved.

sqlalchemy's People

Contributors

mlsalter avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.