Skip to content

ampamias/python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Python exercises for JOUR 479K

Setup

  1. Fork this repository to your GitHub account, then clone it into your local machine and cd into the python directory where it is located.
  2. Install pip
  3. Install Virtualenv Wrapper - where it says mkvirtualenv env1, do mkvirtualenv python instead.
  4. Install Agate using pip: pip install agate
  5. Install Jupyter using pip: pip install jupyter
  6. Start your notebook: jupyter notebook; it should take you to https://localhost:8888/
  7. Using the New drop-down, choose Python 2 notebook.
  8. Name your notebook by clicking on Untitled and typing in "agate" and hitting the OK button.
  9. 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)
  1. Let's the same with candidates (name_raw is candidate name)
  2. Make sure to save your notebook.
  3. Shut down the notebook in terminal by hitting Ctrl-C
  4. Using git, add your notebook file (agate.ipynb), commit it and push to your repository.

About

Python exercises

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published