{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "from matplotlib import style\n", "style.use('fivethirtyeight')\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import datetime as dt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Reflect Tables into SQLAlchemy ORM" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Python SQL toolkit and Object Relational Mapper\n", "import sqlalchemy\n", "from sqlalchemy.ext.automap import automap_base\n", "from sqlalchemy.orm import Session\n", "from sqlalchemy import create_engine, func" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "engine = create_engine(\"sqlite:///hawaii.sqlite\")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# reflect an existing database into a new model\n", "Base = automap_base()\n", "# reflect the tables\n", "Base.prepare(engine, reflect=True)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['measurement', 'station']" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# We can view all of the classes that automap found\n", "Base.classes.keys()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "# Save references to each table\n", "Measurement = Base.classes.measurement\n", "Station = Base.classes.station" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create our session (link) from Python to the DB\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Exploratory Climate Analysis" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Design a query to retrieve the last 12 months of precipitation data and plot the results. \n", "#Starting from the last data point in the database. \n", "\n", "# Calculate the date one year from the last date in data set.\n", "\n", "# Perform a query to retrieve the data and precipitation scores\n", "\n", "# Save the query results as a Pandas DataFrame and set the index to the date column\n", "\n", "# Sort the dataframe by date\n", "\n", "# Use Pandas Plotting with Matplotlib to plot the data\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Use Pandas to calcualte the summary statistics for the precipitation data\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# How many stations are available in this dataset?\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# What are the most active stations?\n", "# List the stations and the counts in descending order.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Using the station id from the previous query, calculate the lowest temperature recorded, \n", "# highest temperature recorded, and average temperature most active station?\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Choose the station with the highest number of temperature observations.\n", "# Query the last 12 months of temperature observation data for this station and plot the results as a histogram\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Write a function called `calc_temps` that will accept start date and end date in the format '%Y-%m-%d' \n", "# and return the minimum, average, and maximum temperatures for that range of dates\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Challenge" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.13" } }, "nbformat": 4, "nbformat_minor": 2 }