- Fork this repository to your GitHub account, then clone it into your local machine and cd into the
python
directory where it is located. - Install pip
- Install Virtualenv Wrapper - where it says
mkvirtualenv env1
, domkvirtualenv python
instead. - Install Agate using pip:
pip install agate
- Install Jupyter using pip:
pip install jupyter
- Start your notebook:
jupyter notebook
; it should take you to https://localhost:8888/ - Using the
New
drop-down, choosePython 2
notebook. - Name your notebook by clicking on
Untitled
and typing in "agate" and hitting the OK button. - Run the following commands, clicking the Cells -> Run Cells drop-down selection after each line:
import agate
results = agate.Table.from_csv("mdcounty2014.csv")
print(results)
row = results.rows[0]
row['jurisdiction']
by_county = results.group_by('jurisdiction')
totals = by_county.aggregate([('county_total', agate.Sum('votes'))])
totals = totals.order_by('county_total', reverse=True)
totals.limit(10).print_bars('jurisdiction', 'county_total', width=80)
- Let's the same with candidates (
name_raw
is candidate name) - Make sure to save your notebook.
- Shut down the notebook in terminal by hitting
Ctrl-C
- Using git, add your notebook file (
agate.ipynb
), commit it and push to your repository.