{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Florida's Water Budget\n", "The Impact of Humans & Nature on Freshwater Sources\n", "\n", ">This activity displays the water use, rainfall and water levels in Florida counties. You can use the code to change the charts and graphs below. Try to find the significance between the data.\n", "\n", ">Sources include the [U.S. Geological Survey](http://waterdata.usgs.gov/fl/nwis/current/?type=precip) and [St. Johns River Water Management District](http://www.sjrwmd.com)\n", "\n", "\n", "### Step 1 - Creating a Checkpoint\n", ">Create a checkpoint by clicking File ==> Save and Checkpoint. If you make a major mistake, you can click File ==> Revert to Checkpoint to reset the Jupyter Notebook online on Binder.org.\n", "\n", "### Importing the Data\n", "\n", ">The next 2 blocks of code imports the data that we will need to examine the caracteristics of many different organisms. You can begin to execute the cells using Shift + Enter to import the data set and continue." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Import modules that contain functions we need\n", "import pandas as pd\n", "import numpy as np\n", "%matplotlib inline\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Our data is a table and is defined as the word 'data'.\n", "# 'data' is set equal to the .csv file that is read by the pandas function.\n", "# The .csv file must be in the same disrectory as the program.\n", "#data = pd.read_csv(\"Public Water Supply FL 2010.csv\")\n", "\n", "# You can also use external links to .xls, .csv, or .txt files and would import useing the same funtion but replaceing the\n", "# file name with the webpage. For example:\n", "data = pd.read_csv(\"https://gist.githubusercontent.com/GoodmanSciences/9d53d0874281a61354cc8a9a962cb926/raw/e379c22e667aa309cc02048bd2b7bb31ce540d60/Public%2520Water%2520Supply%2520FL%25202010.csv\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Pre-Questions\n", ">Using what you've learned in this unit, answer questions 1 & 2 in your coding booklet. The Pre-Questions are listed below for you convienence.\n", "\n", ">1. Access to freshwater is a limiting factor in many ecosystems, what are some\n", "other limiting factors that can effect native populations?\n", "2. Draw a diagram that shows a lake water source. Add and label arrows for\n", "ways that water can be added to the lake. Add and label arrows for the ways\n", "that water can be removed from the lake. (Be sure to include human and\n", "natural / non-human sources)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## PART 1: Water Used by Florida Counties in 2010\n", "\n", ">This table displays the County name, its population, the puplic water supply for that county, and the total water used by that county.\n", "\n", ">Use and modify the sections of code below for Part 1 to answer questions 3-5 in your coding booklet." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# displays the first few rows of the table\n", "data.head(4)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Set variables for scatter plot\n", "x = data.Population\n", "y = data.WaterUsed\n", "\n", "fig = plt.figure(figsize=(15, 6))\n", "plt.scatter(x,y)\n", "plt.xlim(0,3000000)\n", "plt.ylim(0,350)\n", "plt.title('The Relationship Between Population and How Much Water a County Consumes Each Year')\n", "plt.xlabel('Population (individuals)')\n", "plt.ylabel('Water Used (million gallons)')\n", "\n", "# This actually shows the plot\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Creates a new dataset for County\n", "\n", "place = data.groupby(\"County\", as_index = False).sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">This table shows the top 10 water consuming counties, the population, the amount of the population that is connected to public water (PublicSupply), and the total water used by each county." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Orginizes by County with the highest water usage in decending order\n", "#Only displays the top 10 highestest water consuming counties by putting .head(10)\n", "\n", "mostwater = place.sort_values(by=\"WaterUsed\", ascending = False).head(10)\n", "mostwater" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Most Water Consuming Counties in Florida" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Displays a histogram of the top 10 water consuming counties in ascending order\n", "\n", "mostwater.sort_values(by=\"WaterUsed\", ascending=True).plot(x=\"County\", y=\"WaterUsed\", kind=\"barh\", title=\"Top 10 Water Consuming Counties\", legend=False);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">Try to change the histogram so that it displays the County and the Population Total. (Right now it is displaying County and Water Use Total)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## PART 2: Rainfall Additions to the Water Supply \n", "\n", ">Use and modify the sections of code below for Part 2 to answer questions 6-8 in your coding booklet." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Imports more csv files locally\n", "#feb = pd.read_csv(\"Feb2005_FL_rainfall.csv\")\n", "#july = pd.read_csv(\"July2005_FL_rainfall.csv\")\n", "\n", "# Imports more csv files from the web\n", "july = pd.read_csv(\"https://gist.githubusercontent.com/GoodmanSciences/354fa30fb1e506c055621b893b26ebe8/raw/523e483ae4534c9432f91e5d5b7f9fb0356e95e1/Rainfall%2520FL%2520Jul2005.csv\")\n", "feb = pd.read_csv(\"https://gist.githubusercontent.com/GoodmanSciences/7088ff6b7b8e915a87ee987f3b767641/raw/a76a0dd975f95e6c0c5e6ee810e6f6e66faeca9b/Rainfall%2520FL%2520Feb2005.csv\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Rainfall in February 2005 (Inches)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "feb.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Plots rainfall form ascending order\n", "feb.sort_values(by=\"Monthly Total\", ascending=True).plot(x=\"County\", y=\"Monthly Total\", kind=\"barh\", title=\"Rainfall in February (Inches)\", legend=False);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">Try to change the histogram to display the data in **decending** order." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Rainfall in July 2005 (Inches)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "july.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "july.sort_values(by=\"Monthly Total\", ascending=True).plot(x=\"County\", y=\"Monthly Total\", kind=\"barh\", title=\"Rainfall in July (Inches)\", legend=False);" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from IPython.display import Image\n", "from IPython.core.display import HTML \n", "Image(url= 'https://preview.ibb.co/g7Z6sa/Average_Monthly_Water_Consumption.png')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "Image(url= 'https://floridamaps.files.wordpress.com/2015/03/florida-counties.jpg')\n", "\n", "#Double-click to make this image GINORMOUS" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## PART 3: Monitoring Lake Apopka a Freshwater Source for Agriculture \n", "\n", ">Use and modify the sections of code below for Part 3 to answer questions 9 & 10 in your coding booklet." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Imports another csv file locally\n", "#level = pd.read_csv(\"Lake Apopka Waterlevel 2005.csv\")\n", "\n", "# Imports another csv file from the web\n", "level = pd.read_csv(\"https://gist.githubusercontent.com/GoodmanSciences/e63b6cb68cd6ef5235dc8c113ea9995a/raw/39139535f7ef05057ecce1126ea336ca7bcfb879/Lake%2520Apopka%2520Waterlevel%25202005.csv\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Sets Date as index\n", "lev2 = level.set_index(\"Date\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Water Level in February**" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Displays only Feb 1st through the 28th\n", "lev2.loc[\"2/1/2005\":\"2/28/2005\", :]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Water Level in July**" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [], "source": [ "# Displays only July 1st through the 7th\n", "lev2.loc[\"7/1/2005\":\"7/7/2005\", :]" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Plot of all values in level dataset\n", "level.plot('Date', 'Water Level')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "Image(url= 'http://www.floridacountiesmap.com/graphics/orange.gif')" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "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.6.0" } }, "nbformat": 4, "nbformat_minor": 2 }