Download (right-click, save target as ...) this page as a jupyterlab notebook from: Lab12
LAST NAME, FIRST NAME
R00000000
ENGR 1330 Laboratory 12 - In-Lab
import sys
! hostname
! whoami
print(sys.executable)
Population Lines
Use pandas to read a dataframe from the file http://54.243.252.9/engr-1330-webroot/4-Databases/census_18.csv.
Then produce a line plot of the counts by age for the 2010 census, x-axis will be the series age
, y-axis will be the census values for 2010
.
# get the file (using requests, or just download to your computer by hand)
import requests # Module to process http/https requests
#
remote_url="http://54.243.252.9/engr-1330-webroot/4-Databases/census_18.csv" # set the url
rget = requests.get(remote_url, allow_redirects=True) # get the remote resource, follow imbedded links
#
junk = open('census_18.csv','wb').write(rget.content) # extract from the remote the contents, assign to a local file same name
# read the file into a dataframe
import pandas as pd
df = pd.read_csv('census_18.csv')
df.head() # Examine dataframe layout
# plotting
df.plot.line(x="AGE", y="2010", label="duh", c="blue")# Make a plot fill in the parameters
Using your dataframe from above, plot both the 2010 and 2014 census values by age. Plot the 2010 distribution in blue and the 2014 distribution in red.
ax = df.plot.line(x="", y="", label="", c="blue") # fill in the parameters
df.plot.line(x="", y="", label="", c="red", ax=ax)
# your code here
Put the new histogram and the previous one next to each other and explain what you can infer by comparing them.