Projects‎ > ‎

Project 3

Working with Polling Data

Due Tuesday, November 13th at 11:59pm


For this project you are going to write Python programs that analyze presidential polling data.

You will be working with data from the website http://electoral-vote.com.

In particular, you will use the CSV (comma separate values) file here: http://www.electoral-vote.com/evp2012/Pres/pres_polls.csv

Here are the programs that you need to write:

states_by_electoral_votes.py

usage:

python states_by_electoral_votes.py pres_polls.csv

This program will output the a list of states and the District of Columbia sorted by the number of electoral votes for each state.


find_dem_states.py

usage:

python find_dem_states.py pres_polls.csv

Output only democratic states sorted by highest percent to lowest percent based on the latest poll for each state.  A dem state is one in which the dem_poll > gop_poll.  Sort by the difference of dem_poll - gop_poll.


find_gop_states.py

usage:

python find_gop_states.py pres_polls.csv

Output only republican states sorted by highest percent to lowest percent based on the latest poll for each state.  A gop state is one in which the gop_poll > dem_poll.  Sort by the difference of gop_poll - dem_poll.


find_tie_states.py

usage:

python find_tie_states.py pres_polls.csv

Output the states that tied in the latest poll.


find_closest_polls.py

Get the final popular vote results by state and put into a file: final_votes.csv.

usage:

python fine_closet_polls.py pres_polls.csv final_votes.csv

For each state output the poll (pollster and date) that best predicted the election.


find_best_poll.py

usage:

python find_best_poll.py pres_polls.csv final_votes.csv

Find the overall pollster that best predicted the election.


Extra Credit:

Use PyGame to write a program that can chart the polls for a list of states.

usage:

python chart_polls.py <state1> [<state2> ...]

E.g.,

python chart_polls.py CA NV WA OR






ċ
poll_data.py
(1k)
Greg Benson,
Nov 6, 2012, 3:52 PM
ċ
pres_polls.csv
(50k)
Greg Benson,
Nov 6, 2012, 3:52 PM
Comments