The Impact of Humans & Nature on Freshwater Sources
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.
Sources include the U.S. Geological Survey and St. Johns River Water Management District
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.
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.
In [ ]:
# Import modules that contain functions we need
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
In [ ]:
# Our data is a table and is defined as the word 'data'.
# 'data' is set equal to the .csv file that is read by the pandas function.
# The .csv file must be in the same disrectory as the program.
#data = pd.read_csv("Public Water Supply FL 2010.csv")
# You can also use external links to .xls, .csv, or .txt files and would import useing the same funtion but replaceing the
# file name with the webpage. For example:
data = pd.read_csv("https://gist.githubusercontent.com/GoodmanSciences/9d53d0874281a61354cc8a9a962cb926/raw/e379c22e667aa309cc02048bd2b7bb31ce540d60/Public%2520Water%2520Supply%2520FL%25202010.csv")
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.
- Access to freshwater is a limiting factor in many ecosystems, what are some other limiting factors that can effect native populations?
- Draw a diagram that shows a lake water source. Add and label arrows for ways that water can be added to the lake. Add and label arrows for the ways that water can be removed from the lake. (Be sure to include human and natural / non-human sources)
In [ ]:
# displays the first few rows of the table
data.head(4)
In [ ]:
# Set variables for scatter plot
x = data.Population
y = data.WaterUsed
fig = plt.figure(figsize=(15, 6))
plt.scatter(x,y)
plt.xlim(0,3000000)
plt.ylim(0,350)
plt.title('The Relationship Between Population and How Much Water a County Consumes Each Year')
plt.xlabel('Population (individuals)')
plt.ylabel('Water Used (million gallons)')
# This actually shows the plot
plt.show()
In [ ]:
# Creates a new dataset for County
place = data.groupby("County", as_index = False).sum()
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.
In [ ]:
# Orginizes by County with the highest water usage in decending order
#Only displays the top 10 highestest water consuming counties by putting .head(10)
mostwater = place.sort_values(by="WaterUsed", ascending = False).head(10)
mostwater
In [ ]:
# Displays a histogram of the top 10 water consuming counties in ascending order
mostwater.sort_values(by="WaterUsed", ascending=True).plot(x="County", y="WaterUsed", kind="barh", title="Top 10 Water Consuming Counties", legend=False);
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)
In [ ]:
# Imports more csv files locally
#feb = pd.read_csv("Feb2005_FL_rainfall.csv")
#july = pd.read_csv("July2005_FL_rainfall.csv")
# Imports more csv files from the web
july = pd.read_csv("https://gist.githubusercontent.com/GoodmanSciences/354fa30fb1e506c055621b893b26ebe8/raw/523e483ae4534c9432f91e5d5b7f9fb0356e95e1/Rainfall%2520FL%2520Jul2005.csv")
feb = pd.read_csv("https://gist.githubusercontent.com/GoodmanSciences/7088ff6b7b8e915a87ee987f3b767641/raw/a76a0dd975f95e6c0c5e6ee810e6f6e66faeca9b/Rainfall%2520FL%2520Feb2005.csv")
In [ ]:
feb.head()
In [ ]:
# Plots rainfall form ascending order
feb.sort_values(by="Monthly Total", ascending=True).plot(x="County", y="Monthly Total", kind="barh", title="Rainfall in February (Inches)", legend=False);
Try to change the histogram to display the data in decending order.
In [ ]:
july.head()
In [ ]:
july.sort_values(by="Monthly Total", ascending=True).plot(x="County", y="Monthly Total", kind="barh", title="Rainfall in July (Inches)", legend=False);
In [ ]:
from IPython.display import Image
from IPython.core.display import HTML
Image(url= 'https://preview.ibb.co/g7Z6sa/Average_Monthly_Water_Consumption.png')
In [ ]:
Image(url= 'https://floridamaps.files.wordpress.com/2015/03/florida-counties.jpg')
#Double-click to make this image GINORMOUS
In [ ]:
# Imports another csv file locally
#level = pd.read_csv("Lake Apopka Waterlevel 2005.csv")
# Imports another csv file from the web
level = pd.read_csv("https://gist.githubusercontent.com/GoodmanSciences/e63b6cb68cd6ef5235dc8c113ea9995a/raw/39139535f7ef05057ecce1126ea336ca7bcfb879/Lake%2520Apopka%2520Waterlevel%25202005.csv")
In [ ]:
# Sets Date as index
lev2 = level.set_index("Date")
Water Level in February
In [ ]:
# Displays only Feb 1st through the 28th
lev2.loc["2/1/2005":"2/28/2005", :]
Water Level in July
In [ ]:
# Displays only July 1st through the 7th
lev2.loc["7/1/2005":"7/7/2005", :]
In [ ]:
# Plot of all values in level dataset
level.plot('Date', 'Water Level')
In [ ]:
Image(url= 'http://www.floridacountiesmap.com/graphics/orange.gif')