diff --git a/lectures/lecture12/L21DB.sqlite b/lectures/lecture12/L21DB.sqlite new file mode 100644 index 0000000..559d7b1 Binary files /dev/null and b/lectures/lecture12/L21DB.sqlite differ diff --git a/lectures/lecture12/L21_Exercises.ipynb b/lectures/lecture12/L21_Exercises.ipynb new file mode 100644 index 0000000..9187c20 --- /dev/null +++ b/lectures/lecture12/L21_Exercises.ipynb @@ -0,0 +1,9639 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "a812183c", + "metadata": { + "slideshow": { + "slide_type": "slide" + } + }, + "source": [ + "# Lecture 21\n", + "## Tuesday, November 16th, 2021\n", + "### SQL Database Exercise (I)" + ] + }, + { + "cell_type": "markdown", + "id": "224477a3", + "metadata": {}, + "source": [ + "# `SQLite` Exercises\n", + "\n", + "Today you will work with the `candidates.txt` and `contributors.txt` datasets to\n", + "create a database in `python` using `SQLite`. This is a hands-on lecture. For\n", + "once, you may do these tasks in a Jupyter notebook.\n", + "\n", + "The exercises will consist of a sequence of steps to help illustrate basic\n", + "commands." + ] + }, + { + "cell_type": "markdown", + "id": "c07ace30", + "metadata": { + "lines_to_next_cell": 2, + "slideshow": { + "slide_type": "subslide" + } + }, + "source": [ + "\n", + "# Exercise Deliverables\n", + "\n", + "> 1. Make a copy of this notebook and call it `L21_Exercises.ipynb`.\n", + "> 2. For each step in the exercise notebook, there are instructions labeled\n", + "> \"**Do the following:**\" (except for Setup and Interlude). Put all the code\n", + "> for those instructions in a _single cell immediately following_ the\n", + "> instructions. The code in those cells should look like a `python` script.\n", + "> You *must* place comments where appropriate that describe your intentions\n", + "> and understanding. When in doubt add a comment. **Note:** To get the\n", + "> `pandas` tables to display in a cell, use `display()`.\n", + "> 3. Save and close your database. Be sure to upload your database with the\n", + "> lecture exercises. You must name your database **`L21DB.sqlite`**.\n", + "> 4. Commit your completed work to your class `git` repo inside the directory `lectures/lecture21` on the `main` (or `master`) branch.\n" + ] + }, + { + "cell_type": "markdown", + "id": "c89e9aa2", + "metadata": {}, + "source": [ + "## Table of Contents\n", + "\n", + "[Setup](#setup)\n", + "\n", + "[Interlude](#interlude): Not required but highly recommended.\n", + "\n", + "[Step 1](#step_1)\n", + "\n", + "[Step 2](#step_2)\n", + "\n", + "[Step 3](#step_3)\n", + "\n", + "[Step 4](#step_4)\n", + "\n", + "[Step 5](#step_5)\n", + "\n", + "[Step 6](#step_6)\n", + "\n", + "[Step 7](#step_7)\n", + "\n", + "[Step 8](#step_8)\n" + ] + }, + { + "cell_type": "markdown", + "id": "1c8783c4", + "metadata": {}, + "source": [ + "\n", + "# Setup\n", + "\n", + "You should import `sqlite3` again like last time." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "0109c602", + "metadata": {}, + "outputs": [], + "source": [ + "import sqlite3" + ] + }, + { + "cell_type": "markdown", + "id": "c08eaee6", + "metadata": {}, + "source": [ + "We will also use a basic a `pandas` feature to display tables in the database." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a1b888e2", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "pd.set_option('display.width', 500)\n", + "pd.set_option('display.max_rows', None)\n", + "pd.set_option('display.max_columns', 100)\n", + "pd.set_option('display.notebook_repr_html', True)\n", + "\n", + "from IPython.display import display" + ] + }, + { + "cell_type": "markdown", + "id": "b04ab732", + "metadata": {}, + "source": [ + "Now we create the tables in the database (just like last time)." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "6a984b59", + "metadata": {}, + "outputs": [], + "source": [ + "db = sqlite3.connect('L21DB.sqlite')\n", + "cursor = db.cursor()\n", + "cursor.execute(\"DROP TABLE IF EXISTS candidates\")\n", + "cursor.execute(\"DROP TABLE IF EXISTS contributors\")\n", + "cursor.execute(\"PRAGMA foreign_keys=1\")\n", + "\n", + "cursor.execute('''CREATE TABLE candidates (\n", + " id INTEGER PRIMARY KEY NOT NULL, \n", + " first_name TEXT, \n", + " last_name TEXT, \n", + " middle_init TEXT, \n", + " party TEXT NOT NULL)''')\n", + "\n", + "db.commit() # Commit changes to the database\n", + "\n", + "cursor.execute('''CREATE TABLE contributors (\n", + " id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \n", + " last_name TEXT, \n", + " first_name TEXT, \n", + " middle_name TEXT, \n", + " street_1 TEXT, \n", + " street_2 TEXT, \n", + " city TEXT, \n", + " state TEXT, \n", + " zip TEXT, \n", + " amount REAL, \n", + " date DATETIME, \n", + " candidate_id INTEGER NOT NULL, \n", + " FOREIGN KEY(candidate_id) REFERENCES candidates(id))''')\n", + "\n", + "db.commit()" + ] + }, + { + "cell_type": "markdown", + "id": "ecee2ee9", + "metadata": {}, + "source": [ + "Next we load the data for the candidates:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "afe4a443", + "metadata": { + "lines_to_next_cell": 2 + }, + "outputs": [], + "source": [ + "with open (\"candidates.txt\") as candidates:\n", + " next(candidates) # jump over the header\n", + " for line in candidates.readlines():\n", + " cid, first_name, last_name, middle_name, party = line.strip().split('|')\n", + " vals_to_insert = (int(cid), first_name, last_name, middle_name, party)\n", + " cursor.execute('''INSERT INTO candidates \n", + " (id, first_name, last_name, middle_init, party)\n", + " VALUES (?, ?, ?, ?, ?)''', vals_to_insert)\n", + "db.commit()" + ] + }, + { + "cell_type": "markdown", + "id": "980c6b47", + "metadata": {}, + "source": [ + "\n", + "## Interlude\n", + "\n", + "Now that you have values in the tables of the database, it would be convenient\n", + "to be able to visualize those tables in some way. We'll write a little helper\n", + "function to accomplish this." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "3db0ca2d", + "metadata": {}, + "outputs": [], + "source": [ + "def viz_tables(cols, query):\n", + " q = cursor.execute(query).fetchall()\n", + " framelist = dict()\n", + " for i, col_name in enumerate(cols):\n", + " framelist[col_name] = [row[i] for row in q]\n", + " return pd.DataFrame.from_dict(framelist)" + ] + }, + { + "cell_type": "markdown", + "id": "7c770744", + "metadata": {}, + "source": [ + "Here's how we can use our helper function. It gives a pretty nice visualization\n", + "of our table. You should do the same thing with the `contributors` table." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "e77670e5", + "metadata": { + "lines_to_next_cell": 2 + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_initparty
016MikeHuckabeeR
120BarackObamaD
222RudolphGiulianiR
324MikeGravelD
426JohnEdwardsD
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_init party\n", + "0 16 Mike Huckabee R\n", + "1 20 Barack Obama D\n", + "2 22 Rudolph Giuliani R\n", + "3 24 Mike Gravel D\n", + "4 26 John Edwards D" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "candidate_cols = [col[1] for col in cursor.execute(\"PRAGMA table_info(candidates)\")]\n", + "query = '''SELECT * FROM candidates'''\n", + "viz_tables(candidate_cols, query).head()" + ] + }, + { + "cell_type": "markdown", + "id": "27df06b3", + "metadata": {}, + "source": [ + "\n", + "# Step 1\n", + "\n", + "We still need to load the data in the contributors table." + ] + }, + { + "cell_type": "markdown", + "id": "d4724ef9", + "metadata": {}, + "source": [ + "### Do the following:\n", + "\n", + "* Load the data in the `contributors` table by loading the data from the\n", + " `contributors.txt` file. **You are not allowed to use a `for`-loop in this\n", + " task (comprehensions are allowed)**.\n", + "* Display the contributors table." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "a83220e7-015f-4d70-9685-04e6c2da0a1c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\n", + "cursor.execute('''drop TABLE if exists contributors''')\n", + "\n", + "cursor.execute('''CREATE TABLE contributors (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,\n", + "last_name TEXT,first_name TEXT,middle_name TEXT,street_1 TEXT,street_2 TEXT,\n", + "city TEXT,state TEXT,zip TEXT, amount FLOAT(7,3),date DATETIME,candidate_id INTEGER NOT NULL,\n", + "FOREIGN KEY(candidate_id) REFERENCES candidates(id))''') " + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "478f4ff8-2c19-48ad-9593-2dc79c4aa9cc", + "metadata": {}, + "outputs": [], + "source": [ + "cont_list = []\n", + "with open (\"contributors.txt\") as contributors:\n", + " lines = contributors.readlines()\n", + " for i in range(len(lines)):\n", + " words = lines[i].split(\"|\")\n", + " words[-1] = str(words[-1]).replace(\"\\n\", \"\")\n", + " cont_list.append(words[1:])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "781cee78-514a-4768-b07e-7b6c078d7c57", + "metadata": {}, + "outputs": [], + "source": [ + "cursor.executemany('''INSERT INTO contributors(last_name, first_name, middle_name, \n", + "street_1, street_2, city, state, zip, amount, date, candidate_id)VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',cont_list[1:])\n", + "db.commit() " + ] + }, + { + "cell_type": "markdown", + "id": "34cf9400", + "metadata": {}, + "source": [ + "\n", + "# Step 2: Various Queries\n", + "\n", + "We can query our database for entries with certain characteristics. For\n", + "example, we can query the `candidates` table for entries whose middle name\n", + "fields are not empty." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "9fa49a46", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_initparty
034HillaryClintonR.D
139ChristopherDoddJ.D
241FredThompsonD.R
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_init party\n", + "0 34 Hillary Clinton R. D\n", + "1 39 Christopher Dodd J. D\n", + "2 41 Fred Thompson D. R" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM candidates WHERE middle_init <> \"\"'''\n", + "viz_tables(candidate_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "11cea457", + "metadata": {}, + "source": [ + "We can also see how many entries satisfy the query:" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "dd0056dc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3 candidates have a middle initial.\n" + ] + } + ], + "source": [ + "print(\"{} candidates have a middle initial.\".format(viz_tables(candidate_cols, query).shape[0]))" + ] + }, + { + "cell_type": "markdown", + "id": "c6c1c028", + "metadata": {}, + "source": [ + "This used the `shape` method on the returned `pandas` table. You'll get to\n", + "practice counting in SQL later." + ] + }, + { + "cell_type": "markdown", + "id": "48cfbf66", + "metadata": {}, + "source": [ + "### Do the following queries:\n", + "\n", + "* Display the contributors where the state is \"PA\"\n", + "* Display the contributors where the amount contributed is greater than\n", + " $\\$1000.00$.\n", + "* Display the contributors from the state \"UT\" where the amount contributed is\n", + " greater than $\\$1000.00$.\n", + "* Display the contributors who didn't list their state\n", + " - **Hint**: Match `state` to the empty string\n", + "* Display the contributors from \"WA\" or \"PA\"\n", + "* Display the contributors who contributed between $\\$100.00$ and $\\$200.00$.\n", + " - **Hint**: You can use the `BETWEEN 100.00 and 200.00` clause." + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "87b3f39b-c90c-424c-bb71-05bb4931a1bf", + "metadata": {}, + "outputs": [], + "source": [ + "contributor_cols = [col[1] for col in cursor.execute(\"PRAGMA table_info(contributors)\")]\n", + "query = '''SELECT * FROM contributors'''\n", + "#viz_tables(contributor_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "1b975674-46c5-4e65-b8a0-634ad5b53382", + "metadata": {}, + "source": [ + "#### Display the contributors where the state is \"PA\"" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "193c4755-7580-4edc-bda8-79fd646ce216", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
071BUCKLEYWALTERW.1635 COUNTRY ROADBETHLEHEMPA180155718-100.02008-03-0522
172BUCKLEYMARJORIEB.1635 COUNTRY ROADBETHLEHEMPA180155718-100.02008-03-0522
294RaughtPhilipM4714 Plum WayPittsburghPA15201-1046.02008-04-2132
395FerraraJudithD1508 Waterford RoadYardleyPA19067-1100.02008-04-2132
4166ABELJOHNH.422 THOMAS STREETBETHLEHEMPA180153316200.02008-01-2237
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 71 BUCKLEY WALTER W. 1635 COUNTRY ROAD BETHLEHEM PA 180155718 -100.0 2008-03-05 22\n", + "1 72 BUCKLEY MARJORIE B. 1635 COUNTRY ROAD BETHLEHEM PA 180155718 -100.0 2008-03-05 22\n", + "2 94 Raught Philip M 4714 Plum Way Pittsburgh PA 15201 -1046.0 2008-04-21 32\n", + "3 95 Ferrara Judith D 1508 Waterford Road Yardley PA 19067 -1100.0 2008-04-21 32\n", + "4 166 ABEL JOHN H. 422 THOMAS STREET BETHLEHEM PA 180153316 200.0 2008-01-22 37" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "\n", + "query = '''SELECT * FROM contributors WHERE UPPER(state) = \"PA\"'''\n", + "display(viz_tables(contributor_cols, query).head())" + ] + }, + { + "cell_type": "markdown", + "id": "48c22321-95bf-4a71-867c-c48c2cc481f5", + "metadata": {}, + "source": [ + "#### Display the contributors where the amount contributed is greater than $1000.00 ." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "da126e4a-1acb-4a4e-ac26-b01906b2cf53", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
06AkinMike181 Baywood LaneMonticelloAR716551500.02007-05-1816
110AllenJohn D.1052 Cannon Mill DriveNorth AugustaSC298601300.02007-06-2916
214AltesR.D.8600 Moody RoadFort SmithAR729032300.02007-06-2116
316AnthonyJohn211 Long Island DriveHot SpringsAR719132300.02007-06-1216
422BakerDavid2550 Adamsbrooke DriveConwayAR720342300.02007-04-1116
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 6 Akin Mike 181 Baywood Lane Monticello AR 71655 1500.0 2007-05-18 16\n", + "1 10 Allen John D. 1052 Cannon Mill Drive North Augusta SC 29860 1300.0 2007-06-29 16\n", + "2 14 Altes R.D. 8600 Moody Road Fort Smith AR 72903 2300.0 2007-06-21 16\n", + "3 16 Anthony John 211 Long Island Drive Hot Springs AR 71913 2300.0 2007-06-12 16\n", + "4 22 Baker David 2550 Adamsbrooke Drive Conway AR 72034 2300.0 2007-04-11 16" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "query = '''SELECT * FROM contributors WHERE amount > 1000.00'''\n", + "display(viz_tables(contributor_cols, query).head())" + ] + }, + { + "cell_type": "markdown", + "id": "788f5bc9-d6f4-4796-80bf-9b81d1b1c96b", + "metadata": {}, + "source": [ + "#### Display the contributors from the state \"UT\" where the amount contributed is greater than $1000.00 ." + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "47bbdb8b-67be-4730-b82d-632fb2616b38", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
029BuckelLindaPO Box 683130Park CityUT8406831302300.02007-08-1420
131BuckelLindaPO Box 683130Park CityUT8406831304600.02007-08-1420
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 29 Buckel Linda PO Box 683130 Park City UT 840683130 2300.0 2007-08-14 20\n", + "1 31 Buckel Linda PO Box 683130 Park City UT 840683130 4600.0 2007-08-14 20" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "query = '''SELECT * FROM contributors WHERE upper(state) = \"UT\" and amount > 1000.00'''\n", + "display(viz_tables(contributor_cols, query).head())" + ] + }, + { + "cell_type": "markdown", + "id": "2c4a519c-2f86-4c1b-9e19-c22acc739dbb", + "metadata": {}, + "source": [ + "#### Display the contributors who didn't list their state\n", + "Hint: Match state to the empty string" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "b91faf86-aff4-4a40-8379-f1305e0f3d95", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
0126BOURNETRAVISLAGE KAART 77BRASSCHATT02930-500.02008-11-2035
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 126 BOURNE TRAVIS LAGE KAART 77 BRASSCHATT 02930 -500.0 2008-11-20 35" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "query = '''SELECT * FROM contributors WHERE upper(state) = \"\" '''\n", + "display(viz_tables(contributor_cols, query).head())" + ] + }, + { + "cell_type": "markdown", + "id": "9cd8b45c-fb87-41fc-9f9e-00145bc0744a", + "metadata": {}, + "source": [ + "#### Display the contributors from \"WA\" or \"PA\"" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "11145ba7-d239-4fe0-824d-e61b4609d5ca", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
063BURKESUZANNEM.3401 EVANSTONSEATTLEWA981038677-700.02008-03-0522
171BUCKLEYWALTERW.1635 COUNTRY ROADBETHLEHEMPA180155718-100.02008-03-0522
272BUCKLEYMARJORIEB.1635 COUNTRY ROADBETHLEHEMPA180155718-100.02008-03-0522
394RaughtPhilipM4714 Plum WayPittsburghPA15201-1046.02008-04-2132
495FerraraJudithD1508 Waterford RoadYardleyPA19067-1100.02008-04-2132
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 63 BURKE SUZANNE M. 3401 EVANSTON SEATTLE WA 981038677 -700.0 2008-03-05 22\n", + "1 71 BUCKLEY WALTER W. 1635 COUNTRY ROAD BETHLEHEM PA 180155718 -100.0 2008-03-05 22\n", + "2 72 BUCKLEY MARJORIE B. 1635 COUNTRY ROAD BETHLEHEM PA 180155718 -100.0 2008-03-05 22\n", + "3 94 Raught Philip M 4714 Plum Way Pittsburgh PA 15201 -1046.0 2008-04-21 32\n", + "4 95 Ferrara Judith D 1508 Waterford Road Yardley PA 19067 -1100.0 2008-04-21 32" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "query = '''SELECT * FROM contributors WHERE upper(state) = \"WA\" or upper(state) = \"PA\" '''\n", + "display(viz_tables(contributor_cols, query).head())" + ] + }, + { + "cell_type": "markdown", + "id": "e739f2e0-6087-4a74-a86a-03e5701c67bf", + "metadata": {}, + "source": [ + "#### Display the contributors who contributed between 100.00 and 200.00 .\n", + "Hint: You can use the BETWEEN 100.00 and 200.00 clause." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "f4970fb9-52fe-4d56-8630-db11683e8174", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
04AhrensDon4034 Rennellwood WayPleasantonCA94566100.02007-06-2116
15AkinCharles10187 Sugar Creek RoadBentonvilleAR72712100.02007-06-1616
213AllisonRebecca3206 Summit CourtLittle RockAR72227200.02007-06-1216
318ArbogastRobert12900 State Route 56 SEMount SterlingOH43143100.02007-06-2216
428BuckheitBruce8904 KAREN DRFAIRFAXVA220312731100.02007-09-1920
532BuckThomas4206 Terrace StreetKansas CityMO64111100.02007-09-2520
633BuckJayK.1855 Old Willow Rd Unit 322NorthfieldIL600932918200.02007-09-1220
738BucherIdaM1400 Warnall AveLos AngelesCA900245333100.02007-07-1020
847BuchananJohn2025 NW 29th RdBoca RatonFL334316303200.02007-08-1420
9101AaronsonRebecca2000 Village Green Dr Apt 12Mill CreekWA980125787100.02008-02-0834
10104AaronsElaine481 Buck Island Rd Apt 17AAPT 17AWest YarmouthMA026733300100.02008-02-0834
11106AaronShirley101 Cherry AveHavanaFL323331311100.02008-02-2934
12107AaronsonRebecca2000 Village Green Dr Apt 12Mill CreekWA980125787100.02008-02-1434
13108AaronShirley101 Cherry AveHavanaFL323331311100.02008-02-2434
14109AaronShirley101 Cherry AveHavanaFL323331311100.02008-02-2234
15110AaronShirley101 Cherry AveHavanaFL323331311100.02008-02-1734
16113AaronShirley101 Cherry AveHavanaFL323331311100.02008-02-0834
17114AaronShirley101 Cherry AveHavanaFL323331311100.02008-02-0334
18116AaronPatricia418 NW 35th StOklahoma CityOK731188602200.02008-02-2634
19117AaronPatricia418 NW 35th StOklahoma CityOK731188602100.02008-02-1234
20119AaronJim2178 Fairway CirCantonMI481885097200.02008-02-2934
21122AaronCarolePO Box 1806OgunquitME039071806100.02008-02-0334
22125AanonsenLin897 Raymond AveSaint PaulMN551141508100.02008-02-0834
23130ABTSHENRYP. O. BOX 7299INCLINE VILLAGENV894527299100.02007-07-1335
24134ABREUKEVINM.1305 GARDEN GLEN LANEPEARLANDTX775816547150.02007-08-0935
25147ABBOTTWELDONS.777 EAST SOUTH TEMPLE 4ESALT LAKE CITYUT841021269100.02007-09-2935
26149ABBOTTGERALDF.389 BENEFIT STREETPROVIDENCERI029032946100.02007-09-1535
27150ABBOTTGERALDF.389 BENEFIT STREETPROVIDENCERI029032946100.02007-08-1535
28154ABBOTTRONALDLEANDER5453 HAWTHORNE STREETMONTCLAIRCA917632551200.02008-01-3137
29155ABBOTTRONALDLEANDER5453 HAWTHORNE STREETMONTCLAIRCA917632551100.02008-01-0837
30158ABBOTDAVIDM.56 SALEM STREETANDOVERMA018102114200.02008-01-2137
31162ABACHERLISHIRLEYM.29875 NEWPORT ROADMENIFEECA925849524150.02008-01-2837
32166ABELJOHNH.422 THOMAS STREETBETHLEHEMPA180153316200.02008-01-2237
33167ABELMARLINGL.14 HANGING MOSS LANEGREENVILLESC296155069100.02008-01-2237
34168ABELRUDOLPH4532 OCEAN BLVD.# 108SARASOTAFL342421337100.02008-01-0837
35171ABESHAUSMERRILLM.1801 N. HEREFORD DRIVEFLAGSTAFFAZ860011121120.02008-01-1637
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 4 Ahrens Don 4034 Rennellwood Way Pleasanton CA 94566 100.0 2007-06-21 16\n", + "1 5 Akin Charles 10187 Sugar Creek Road Bentonville AR 72712 100.0 2007-06-16 16\n", + "2 13 Allison Rebecca 3206 Summit Court Little Rock AR 72227 200.0 2007-06-12 16\n", + "3 18 Arbogast Robert 12900 State Route 56 SE Mount Sterling OH 43143 100.0 2007-06-22 16\n", + "4 28 Buckheit Bruce 8904 KAREN DR FAIRFAX VA 220312731 100.0 2007-09-19 20\n", + "5 32 Buck Thomas 4206 Terrace Street Kansas City MO 64111 100.0 2007-09-25 20\n", + "6 33 Buck Jay K. 1855 Old Willow Rd Unit 322 Northfield IL 600932918 200.0 2007-09-12 20\n", + "7 38 Bucher Ida M 1400 Warnall Ave Los Angeles CA 900245333 100.0 2007-07-10 20\n", + "8 47 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 200.0 2007-08-14 20\n", + "9 101 Aaronson Rebecca 2000 Village Green Dr Apt 12 Mill Creek WA 980125787 100.0 2008-02-08 34\n", + "10 104 Aarons Elaine 481 Buck Island Rd Apt 17A APT 17A West Yarmouth MA 026733300 100.0 2008-02-08 34\n", + "11 106 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.0 2008-02-29 34\n", + "12 107 Aaronson Rebecca 2000 Village Green Dr Apt 12 Mill Creek WA 980125787 100.0 2008-02-14 34\n", + "13 108 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.0 2008-02-24 34\n", + "14 109 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.0 2008-02-22 34\n", + "15 110 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.0 2008-02-17 34\n", + "16 113 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.0 2008-02-08 34\n", + "17 114 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.0 2008-02-03 34\n", + "18 116 Aaron Patricia 418 NW 35th St Oklahoma City OK 731188602 200.0 2008-02-26 34\n", + "19 117 Aaron Patricia 418 NW 35th St Oklahoma City OK 731188602 100.0 2008-02-12 34\n", + "20 119 Aaron Jim 2178 Fairway Cir Canton MI 481885097 200.0 2008-02-29 34\n", + "21 122 Aaron Carole PO Box 1806 Ogunquit ME 039071806 100.0 2008-02-03 34\n", + "22 125 Aanonsen Lin 897 Raymond Ave Saint Paul MN 551141508 100.0 2008-02-08 34\n", + "23 130 ABTS HENRY P. O. BOX 7299 INCLINE VILLAGE NV 894527299 100.0 2007-07-13 35\n", + "24 134 ABREU KEVIN M. 1305 GARDEN GLEN LANE PEARLAND TX 775816547 150.0 2007-08-09 35\n", + "25 147 ABBOTT WELDON S. 777 EAST SOUTH TEMPLE 4E SALT LAKE CITY UT 841021269 100.0 2007-09-29 35\n", + "26 149 ABBOTT GERALD F. 389 BENEFIT STREET PROVIDENCE RI 029032946 100.0 2007-09-15 35\n", + "27 150 ABBOTT GERALD F. 389 BENEFIT STREET PROVIDENCE RI 029032946 100.0 2007-08-15 35\n", + "28 154 ABBOTT RONALD LEANDER 5453 HAWTHORNE STREET MONTCLAIR CA 917632551 200.0 2008-01-31 37\n", + "29 155 ABBOTT RONALD LEANDER 5453 HAWTHORNE STREET MONTCLAIR CA 917632551 100.0 2008-01-08 37\n", + "30 158 ABBOT DAVID M. 56 SALEM STREET ANDOVER MA 018102114 200.0 2008-01-21 37\n", + "31 162 ABACHERLI SHIRLEY M. 29875 NEWPORT ROAD MENIFEE CA 925849524 150.0 2008-01-28 37\n", + "32 166 ABEL JOHN H. 422 THOMAS STREET BETHLEHEM PA 180153316 200.0 2008-01-22 37\n", + "33 167 ABEL MARLING L. 14 HANGING MOSS LANE GREENVILLE SC 296155069 100.0 2008-01-22 37\n", + "34 168 ABEL RUDOLPH 4532 OCEAN BLVD. # 108 SARASOTA FL 342421337 100.0 2008-01-08 37\n", + "35 171 ABESHAUS MERRILL M. 1801 N. HEREFORD DRIVE FLAGSTAFF AZ 860011121 120.0 2008-01-16 37" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#query = '''SELECT * FROM contributors WHERE amount >= 100.00 and amount <= 200.00'''\n", + "query = '''SELECT * FROM contributors WHERE amount BETWEEN 100.00 and 200.00'''\n", + "display(viz_tables(contributor_cols, query))" + ] + }, + { + "cell_type": "markdown", + "id": "9f9c6509", + "metadata": {}, + "source": [ + "\n", + "# Step 3: Sorting\n", + "\n", + "It could be beneficial to sort by one of the attributes in the database. The\n", + "following cell contains a basic sorting demo. Run it and try to understand what\n", + "happened." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "00cda7c8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_initparty
041FredThompsonD.R
139ChristopherDoddJ.D
238TomTancredoR
337JohnMcCainR
436SamuelBrownbackR
535MittRomneyR
634HillaryClintonR.D
733JosephBidenD
832RonPaulR
931DennisKucinichD
1030DuncanHunterR
1129BillRichardsonD
1226JohnEdwardsD
1324MikeGravelD
1422RudolphGiulianiR
1520BarackObamaD
1616MikeHuckabeeR
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_init party\n", + "0 41 Fred Thompson D. R\n", + "1 39 Christopher Dodd J. D\n", + "2 38 Tom Tancredo R\n", + "3 37 John McCain R\n", + "4 36 Samuel Brownback R\n", + "5 35 Mitt Romney R\n", + "6 34 Hillary Clinton R. D\n", + "7 33 Joseph Biden D\n", + "8 32 Ron Paul R\n", + "9 31 Dennis Kucinich D\n", + "10 30 Duncan Hunter R\n", + "11 29 Bill Richardson D\n", + "12 26 John Edwards D\n", + "13 24 Mike Gravel D\n", + "14 22 Rudolph Giuliani R\n", + "15 20 Barack Obama D\n", + "16 16 Mike Huckabee R" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM candidates ORDER BY id DESC'''\n", + "viz_tables(candidate_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "c81c123a", + "metadata": {}, + "source": [ + "### Do the following sorts on the `contributors` table:\n", + "\n", + "* Sort the `candidates` table by `last_name`.\n", + "* Sort the `contributors` table by the `amount` in descending order where `amount`\n", + " is restricted to be between $\\$1000.00$ and $\\$5000.00$.\n", + " - **Hint:** In your SQL command, start with getting the amount between the\n", + " specified range followed by the sort. This will all be done in one line.\n", + "* Sort the contributors who donated between $\\$1000.00$ and $\\$5000.00$ by\n", + " `candidate_id` and then by `amount` in descending order.\n", + " - **Hint**: Multiple orderings can be accomplished by separating requests\n", + " after `ORDER BY` with commas.\n", + " - e.g. `ORDER BY amount ASC, last_name DESC`" + ] + }, + { + "cell_type": "markdown", + "id": "d5f5a842-60d4-406c-ad17-de2032580d55", + "metadata": {}, + "source": [ + "#### Sort the candidates table by last_name." + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "c0ec25a0-83a3-4da8-b0bf-d2a47ed53f37", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_initparty
041FredThompsonD.R
138TomTancredoR
235MittRomneyR
329BillRichardsonD
432RonPaulR
520BarackObamaD
637JohnMcCainR
731DennisKucinichD
830DuncanHunterR
916MikeHuckabeeR
1024MikeGravelD
1122RudolphGiulianiR
1226JohnEdwardsD
1339ChristopherDoddJ.D
1434HillaryClintonR.D
1536SamuelBrownbackR
1633JosephBidenD
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_init party\n", + "0 41 Fred Thompson D. R\n", + "1 38 Tom Tancredo R\n", + "2 35 Mitt Romney R\n", + "3 29 Bill Richardson D\n", + "4 32 Ron Paul R\n", + "5 20 Barack Obama D\n", + "6 37 John McCain R\n", + "7 31 Dennis Kucinich D\n", + "8 30 Duncan Hunter R\n", + "9 16 Mike Huckabee R\n", + "10 24 Mike Gravel D\n", + "11 22 Rudolph Giuliani R\n", + "12 26 John Edwards D\n", + "13 39 Christopher Dodd J. D\n", + "14 34 Hillary Clinton R. D\n", + "15 36 Samuel Brownback R\n", + "16 33 Joseph Biden D" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM candidates ORDER BY last_name DESC'''\n", + "viz_tables(candidate_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "ad934da2-cca3-4b58-8152-5428b63821f1", + "metadata": {}, + "source": [ + "#### Sort the contributors table by the amount in descending order where amount is restricted to be between 1000.00 and 5000.00 .\n", + "\n", + "Hint: In your SQL command, start with getting the amount between the specified range followed by the sort. This will all be done in one line." + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "f991e772-9e2b-46b3-8fdd-609e82a99021", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
031BuckelLindaPO Box 683130Park CityUT8406831304600.02007-08-1420
1160ABATEMARIAELENA1291 NIGHTINGALE AVENUEMIAMI SPRINGSFL3316638322600.02008-01-2537
214AltesR.D.8600 Moody RoadFort SmithAR729032300.02007-06-2116
316AnthonyJohn211 Long Island DriveHot SpringsAR719132300.02007-06-1216
422BakerDavid2550 Adamsbrooke DriveConwayAR720342300.02007-04-1116
529BuckelLindaPO Box 683130Park CityUT8406831302300.02007-08-1420
634BuckBlaineM45 Eaton AveCamdenME0484317522300.02007-09-3020
7136ABRAMOWITZNIRA411 HARBOR ROADSOUTHPORTCT0689013762300.02007-09-1435
86AkinMike181 Baywood LaneMonticelloAR716551500.02007-05-1816
910AllenJohn D.1052 Cannon Mill DriveNorth AugustaSC298601300.02007-06-2916
1046BuchananJohn2025 NW 29th RdBoca RatonFL3343163031300.02007-08-0920
11175ABRAHAMSALEMA.P.O. BOX 7CANADIANTX7901400071300.02008-01-3037
129AllenJohn D.1052 Cannon Mill DriveNorth AugustaSC298601000.02007-06-1116
1311AllisonJohn W.P.O. Box 1089ConwayAR720331000.02007-05-1816
1412AllisonRebecca3206 Summit CourtLittle RockAR722271000.02007-04-2516
1520AtiqOmar7200 S Hazel StreetPine BluffAR716031000.02007-05-1816
1621AtiqOmar7200 S Hazel StreetPine BluffAR716031000.02007-06-2716
1724BanksCharlesP.O. Box 251310Little RockAR722251000.02007-05-1416
1845BuchananJohn2025 NW 29th RdBoca RatonFL3343163031000.02007-08-2820
19123AaronBarbara2298 Pacific Ave # 6San FranciscoCA9411514351000.02008-02-1134
20139ABOUBAKARENASAR1400 SAN MIGUEL DRIVECORONA DEL MARCA9262513001000.02007-07-0935
21157ABBOTTMIKEE.4516 OSPREY LNDGNICEVILLEFL3257868101000.02008-01-1537
22174ABRAHAMSALEMA.P.O. BOX 7CANADIANTX7901400071000.02008-01-1737
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 31 Buckel Linda PO Box 683130 Park City UT 840683130 4600.0 2007-08-14 20\n", + "1 160 ABATE MARIA ELENA 1291 NIGHTINGALE AVENUE MIAMI SPRINGS FL 331663832 2600.0 2008-01-25 37\n", + "2 14 Altes R.D. 8600 Moody Road Fort Smith AR 72903 2300.0 2007-06-21 16\n", + "3 16 Anthony John 211 Long Island Drive Hot Springs AR 71913 2300.0 2007-06-12 16\n", + "4 22 Baker David 2550 Adamsbrooke Drive Conway AR 72034 2300.0 2007-04-11 16\n", + "5 29 Buckel Linda PO Box 683130 Park City UT 840683130 2300.0 2007-08-14 20\n", + "6 34 Buck Blaine M 45 Eaton Ave Camden ME 048431752 2300.0 2007-09-30 20\n", + "7 136 ABRAMOWITZ NIRA 411 HARBOR ROAD SOUTHPORT CT 068901376 2300.0 2007-09-14 35\n", + "8 6 Akin Mike 181 Baywood Lane Monticello AR 71655 1500.0 2007-05-18 16\n", + "9 10 Allen John D. 1052 Cannon Mill Drive North Augusta SC 29860 1300.0 2007-06-29 16\n", + "10 46 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 1300.0 2007-08-09 20\n", + "11 175 ABRAHAM SALEM A. P.O. BOX 7 CANADIAN TX 790140007 1300.0 2008-01-30 37\n", + "12 9 Allen John D. 1052 Cannon Mill Drive North Augusta SC 29860 1000.0 2007-06-11 16\n", + "13 11 Allison John W. P.O. Box 1089 Conway AR 72033 1000.0 2007-05-18 16\n", + "14 12 Allison Rebecca 3206 Summit Court Little Rock AR 72227 1000.0 2007-04-25 16\n", + "15 20 Atiq Omar 7200 S Hazel Street Pine Bluff AR 71603 1000.0 2007-05-18 16\n", + "16 21 Atiq Omar 7200 S Hazel Street Pine Bluff AR 71603 1000.0 2007-06-27 16\n", + "17 24 Banks Charles P.O. Box 251310 Little Rock AR 72225 1000.0 2007-05-14 16\n", + "18 45 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 1000.0 2007-08-28 20\n", + "19 123 Aaron Barbara 2298 Pacific Ave # 6 San Francisco CA 941151435 1000.0 2008-02-11 34\n", + "20 139 ABOUBAKARE NASAR 1400 SAN MIGUEL DRIVE CORONA DEL MAR CA 926251300 1000.0 2007-07-09 35\n", + "21 157 ABBOTT MIKE E. 4516 OSPREY LNDG NICEVILLE FL 325786810 1000.0 2008-01-15 37\n", + "22 174 ABRAHAM SALEM A. P.O. BOX 7 CANADIAN TX 790140007 1000.0 2008-01-17 37" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM contributors WHERE amount BETWEEN 1000.00 and 5000.00 ORDER BY amount DESC '''\n", + "viz_tables(contributor_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "a7802307-51f5-4e10-94e2-3d6cf329a8c8", + "metadata": {}, + "source": [ + "#### Sort the contributors who donated between $1000.00 and $5000.00 by candidate_id and then by amount in descending order.\n", + "Hint: Multiple orderings can be accomplished by separating requests after ORDER BY with commas.\n", + "e.g. ORDER BY amount ASC, last_name DESC" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "5797ada0-a8c4-4704-bd19-df723a8c2b68", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
014AltesR.D.8600 Moody RoadFort SmithAR729032300.02007-06-2116
116AnthonyJohn211 Long Island DriveHot SpringsAR719132300.02007-06-1216
222BakerDavid2550 Adamsbrooke DriveConwayAR720342300.02007-04-1116
36AkinMike181 Baywood LaneMonticelloAR716551500.02007-05-1816
410AllenJohn D.1052 Cannon Mill DriveNorth AugustaSC298601300.02007-06-2916
59AllenJohn D.1052 Cannon Mill DriveNorth AugustaSC298601000.02007-06-1116
611AllisonJohn W.P.O. Box 1089ConwayAR720331000.02007-05-1816
712AllisonRebecca3206 Summit CourtLittle RockAR722271000.02007-04-2516
820AtiqOmar7200 S Hazel StreetPine BluffAR716031000.02007-05-1816
921AtiqOmar7200 S Hazel StreetPine BluffAR716031000.02007-06-2716
1024BanksCharlesP.O. Box 251310Little RockAR722251000.02007-05-1416
1131BuckelLindaPO Box 683130Park CityUT8406831304600.02007-08-1420
1229BuckelLindaPO Box 683130Park CityUT8406831302300.02007-08-1420
1334BuckBlaineM45 Eaton AveCamdenME0484317522300.02007-09-3020
1446BuchananJohn2025 NW 29th RdBoca RatonFL3343163031300.02007-08-0920
1545BuchananJohn2025 NW 29th RdBoca RatonFL3343163031000.02007-08-2820
16123AaronBarbara2298 Pacific Ave # 6San FranciscoCA9411514351000.02008-02-1134
17136ABRAMOWITZNIRA411 HARBOR ROADSOUTHPORTCT0689013762300.02007-09-1435
18139ABOUBAKARENASAR1400 SAN MIGUEL DRIVECORONA DEL MARCA9262513001000.02007-07-0935
19160ABATEMARIAELENA1291 NIGHTINGALE AVENUEMIAMI SPRINGSFL3316638322600.02008-01-2537
20175ABRAHAMSALEMA.P.O. BOX 7CANADIANTX7901400071300.02008-01-3037
21157ABBOTTMIKEE.4516 OSPREY LNDGNICEVILLEFL3257868101000.02008-01-1537
22174ABRAHAMSALEMA.P.O. BOX 7CANADIANTX7901400071000.02008-01-1737
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 14 Altes R.D. 8600 Moody Road Fort Smith AR 72903 2300.0 2007-06-21 16\n", + "1 16 Anthony John 211 Long Island Drive Hot Springs AR 71913 2300.0 2007-06-12 16\n", + "2 22 Baker David 2550 Adamsbrooke Drive Conway AR 72034 2300.0 2007-04-11 16\n", + "3 6 Akin Mike 181 Baywood Lane Monticello AR 71655 1500.0 2007-05-18 16\n", + "4 10 Allen John D. 1052 Cannon Mill Drive North Augusta SC 29860 1300.0 2007-06-29 16\n", + "5 9 Allen John D. 1052 Cannon Mill Drive North Augusta SC 29860 1000.0 2007-06-11 16\n", + "6 11 Allison John W. P.O. Box 1089 Conway AR 72033 1000.0 2007-05-18 16\n", + "7 12 Allison Rebecca 3206 Summit Court Little Rock AR 72227 1000.0 2007-04-25 16\n", + "8 20 Atiq Omar 7200 S Hazel Street Pine Bluff AR 71603 1000.0 2007-05-18 16\n", + "9 21 Atiq Omar 7200 S Hazel Street Pine Bluff AR 71603 1000.0 2007-06-27 16\n", + "10 24 Banks Charles P.O. Box 251310 Little Rock AR 72225 1000.0 2007-05-14 16\n", + "11 31 Buckel Linda PO Box 683130 Park City UT 840683130 4600.0 2007-08-14 20\n", + "12 29 Buckel Linda PO Box 683130 Park City UT 840683130 2300.0 2007-08-14 20\n", + "13 34 Buck Blaine M 45 Eaton Ave Camden ME 048431752 2300.0 2007-09-30 20\n", + "14 46 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 1300.0 2007-08-09 20\n", + "15 45 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 1000.0 2007-08-28 20\n", + "16 123 Aaron Barbara 2298 Pacific Ave # 6 San Francisco CA 941151435 1000.0 2008-02-11 34\n", + "17 136 ABRAMOWITZ NIRA 411 HARBOR ROAD SOUTHPORT CT 068901376 2300.0 2007-09-14 35\n", + "18 139 ABOUBAKARE NASAR 1400 SAN MIGUEL DRIVE CORONA DEL MAR CA 926251300 1000.0 2007-07-09 35\n", + "19 160 ABATE MARIA ELENA 1291 NIGHTINGALE AVENUE MIAMI SPRINGS FL 331663832 2600.0 2008-01-25 37\n", + "20 175 ABRAHAM SALEM A. P.O. BOX 7 CANADIAN TX 790140007 1300.0 2008-01-30 37\n", + "21 157 ABBOTT MIKE E. 4516 OSPREY LNDG NICEVILLE FL 325786810 1000.0 2008-01-15 37\n", + "22 174 ABRAHAM SALEM A. P.O. BOX 7 CANADIAN TX 790140007 1000.0 2008-01-17 37" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM contributors WHERE amount BETWEEN 1000.00 and 5000.00 ORDER BY candidate_id, amount DESC '''\n", + "viz_tables(contributor_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "82d82482", + "metadata": {}, + "source": [ + "\n", + "# Step 4: Selecting Columns\n", + "\n", + "So far, we've been selecting all columns from a table (i.e. `SELECT * FROM`).\n", + "Often, we just want to select specific columns (e.g. `SELECT amount FROM`)." + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "46549116", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_nameparty
0HuckabeeR
1ObamaD
2GiulianiR
3GravelD
4EdwardsD
5RichardsonD
6HunterR
7KucinichD
8PaulR
9BidenD
10ClintonD
11RomneyR
12BrownbackR
13McCainR
14TancredoR
15DoddD
16ThompsonR
\n", + "
" + ], + "text/plain": [ + " last_name party\n", + "0 Huckabee R\n", + "1 Obama D\n", + "2 Giuliani R\n", + "3 Gravel D\n", + "4 Edwards D\n", + "5 Richardson D\n", + "6 Hunter R\n", + "7 Kucinich D\n", + "8 Paul R\n", + "9 Biden D\n", + "10 Clinton D\n", + "11 Romney R\n", + "12 Brownback R\n", + "13 McCain R\n", + "14 Tancredo R\n", + "15 Dodd D\n", + "16 Thompson R" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT last_name, party FROM candidates'''\n", + "viz_tables(['last_name', 'party'], query)" + ] + }, + { + "cell_type": "markdown", + "id": "b771f415", + "metadata": {}, + "source": [ + "Using the `DISTINCT` clause, you remove duplicate rows." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "220d784c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
party
0R
1D
\n", + "
" + ], + "text/plain": [ + " party\n", + "0 R\n", + "1 D" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT DISTINCT party FROM candidates'''\n", + "viz_tables(['party'], query)" + ] + }, + { + "cell_type": "markdown", + "id": "24f23ab3", + "metadata": {}, + "source": [ + "### Do the following:\n", + "\n", + "* Get the first and last name of contributors. Make sure each row has distinct\n", + " values." + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "04c90152-a468-402f-abff-d24b5744ef7b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
first_namelast_name
0StevenAgee
1DonAhrens
2CharlesAkin
3MikeAkin
4RebeccaAkin
5BrittniAldridge
6John D.Allen
7John W.Allison
8RebeccaAllison
9R.D.Altes
10DaleAndres
11JohnAnthony
12RobertArbogast
13WilliamArdle
14OmarAtiq
15DavidBaker
16DavidBancroft
17CharlesBanks
18JohnBarbee
19SteveBuckler
20BruceBuckheit
21LindaBuckel
22ThomasBuck
23JayBuck
24BlaineBuck
25BarbaraBuck
26Mark MBuchman
27IdaBucher
28ElizabethBuchanek
29JohnBuchanan
30RyanHarrison
31HERBERTBYNUM
32MARGARETBYINGTON
33BOBBYERS
34AUDREYBYERS
35KRYSTIEBUSH
36ERICBUSH
37SUSANBURTON
38STEVENBURTON
39GLENNBURTON
40CRAIGBURKHARDT
41BARBARABURKHARDT
42SUZANNEBURKE
43GAILBURKE
44DONALDBURKE
45RONALDBURGERT
46BARTLEBULL
47DANIELBUKOWSKI
48MARGARETBUISSON
49WALTERBUCKLEY
50MARJORIEBUCKLEY
51JOHNBRUNO
52IRENEBRUNO
53TIMOTHYBROWN
54BryanSchuff
55JamesHobbs
56AnoopRanganath
57MichaelNystrom
58NinaMuse
59JamesWaddell
60WilliamBrucks
61DavidKuehn
62JeanetteVerster
63RichardUihlein
64RobertEskenberry
65AlanFroehling
66MarciaDuryea
67LouisePerreault
68TimurRozenfeld
69ChristopherKazor
70ThomasLehner
71JosephPlummer
72PhilipRaught
73JudithFerrara
74CathleenJohnson
75BradleySanford
76BruceGaarder
77HyeokchanChoe
78RichardJacobs
79RebeccaAaronson
80ElaineAarons
81ShirleyAaron
82ElizabethReid
83ThomasReich
84SharronAaron
85PatriciaAaron
86JimAaron
87CaroleAaron
88BarbaraAaron
89LinAanonsen
90TRAVISBOURNE
91BRIANSECRIST
92TRAVISTOLLESTRUP
93DEANACCORD
94HENRYABTS
95LANNYABSHIER
96DIANAABSHIER
97KEVINABREU
98NIRAABRAMOWITZ
99MICHAELABRAMS
100KENABRAMOWITZ
101NASARABOUBAKARE
102PATRICIAABEGG
103THOMASABDELLA
104WELDONABBOTT
105GERALDABBOTT
106ZAINULABEDIN
107SYBILABBOTT
108RONALDABBOTT
109ROBERTABBOTT
110MIKEABBOTT
111DAVIDABBOT
112PAULINEABBO
113MARIAABATE
114PETERABAIR
115SHIRLEYABACHERLI
116CHARLESAARONS
117JOHNABEL
118MARLINGABEL
119RUDOLPHABEL
120RODNEYABELE
121DENISABERCROMBIE
122MERRILLABESHAUS
123GEORGEABRAHAM
124PETERABRAHAMSON
125SALEMABRAHAM
\n", + "
" + ], + "text/plain": [ + " first_name last_name\n", + "0 Steven Agee\n", + "1 Don Ahrens\n", + "2 Charles Akin\n", + "3 Mike Akin\n", + "4 Rebecca Akin\n", + "5 Brittni Aldridge\n", + "6 John D. Allen\n", + "7 John W. Allison\n", + "8 Rebecca Allison\n", + "9 R.D. Altes\n", + "10 Dale Andres\n", + "11 John Anthony\n", + "12 Robert Arbogast\n", + "13 William Ardle\n", + "14 Omar Atiq\n", + "15 David Baker\n", + "16 David Bancroft\n", + "17 Charles Banks\n", + "18 John Barbee\n", + "19 Steve Buckler\n", + "20 Bruce Buckheit\n", + "21 Linda Buckel\n", + "22 Thomas Buck\n", + "23 Jay Buck\n", + "24 Blaine Buck\n", + "25 Barbara Buck\n", + "26 Mark M Buchman\n", + "27 Ida Bucher\n", + "28 Elizabeth Buchanek\n", + "29 John Buchanan\n", + "30 Ryan Harrison\n", + "31 HERBERT BYNUM\n", + "32 MARGARET BYINGTON\n", + "33 BOB BYERS\n", + "34 AUDREY BYERS\n", + "35 KRYSTIE BUSH\n", + "36 ERIC BUSH\n", + "37 SUSAN BURTON\n", + "38 STEVEN BURTON\n", + "39 GLENN BURTON\n", + "40 CRAIG BURKHARDT\n", + "41 BARBARA BURKHARDT\n", + "42 SUZANNE BURKE\n", + "43 GAIL BURKE\n", + "44 DONALD BURKE\n", + "45 RONALD BURGERT\n", + "46 BARTLE BULL\n", + "47 DANIEL BUKOWSKI\n", + "48 MARGARET BUISSON\n", + "49 WALTER BUCKLEY\n", + "50 MARJORIE BUCKLEY\n", + "51 JOHN BRUNO\n", + "52 IRENE BRUNO\n", + "53 TIMOTHY BROWN\n", + "54 Bryan Schuff\n", + "55 James Hobbs\n", + "56 Anoop Ranganath\n", + "57 Michael Nystrom\n", + "58 Nina Muse\n", + "59 James Waddell\n", + "60 William Brucks\n", + "61 David Kuehn\n", + "62 Jeanette Verster\n", + "63 Richard Uihlein\n", + "64 Robert Eskenberry\n", + "65 Alan Froehling\n", + "66 Marcia Duryea\n", + "67 Louise Perreault\n", + "68 Timur Rozenfeld\n", + "69 Christopher Kazor\n", + "70 Thomas Lehner\n", + "71 Joseph Plummer\n", + "72 Philip Raught\n", + "73 Judith Ferrara\n", + "74 Cathleen Johnson\n", + "75 Bradley Sanford\n", + "76 Bruce Gaarder\n", + "77 Hyeokchan Choe\n", + "78 Richard Jacobs\n", + "79 Rebecca Aaronson\n", + "80 Elaine Aarons\n", + "81 Shirley Aaron\n", + "82 Elizabeth Reid\n", + "83 Thomas Reich\n", + "84 Sharron Aaron\n", + "85 Patricia Aaron\n", + "86 Jim Aaron\n", + "87 Carole Aaron\n", + "88 Barbara Aaron\n", + "89 Lin Aanonsen\n", + "90 TRAVIS BOURNE\n", + "91 BRIAN SECRIST\n", + "92 TRAVIS TOLLESTRUP\n", + "93 DEAN ACCORD\n", + "94 HENRY ABTS\n", + "95 LANNY ABSHIER\n", + "96 DIANA ABSHIER\n", + "97 KEVIN ABREU\n", + "98 NIRA ABRAMOWITZ\n", + "99 MICHAEL ABRAMS\n", + "100 KEN ABRAMOWITZ\n", + "101 NASAR ABOUBAKARE\n", + "102 PATRICIA ABEGG\n", + "103 THOMAS ABDELLA\n", + "104 WELDON ABBOTT\n", + "105 GERALD ABBOTT\n", + "106 ZAINUL ABEDIN\n", + "107 SYBIL ABBOTT\n", + "108 RONALD ABBOTT\n", + "109 ROBERT ABBOTT\n", + "110 MIKE ABBOTT\n", + "111 DAVID ABBOT\n", + "112 PAULINE ABBO\n", + "113 MARIA ABATE\n", + "114 PETER ABAIR\n", + "115 SHIRLEY ABACHERLI\n", + "116 CHARLES AARONS\n", + "117 JOHN ABEL\n", + "118 MARLING ABEL\n", + "119 RUDOLPH ABEL\n", + "120 RODNEY ABELE\n", + "121 DENIS ABERCROMBIE\n", + "122 MERRILL ABESHAUS\n", + "123 GEORGE ABRAHAM\n", + "124 PETER ABRAHAMSON\n", + "125 SALEM ABRAHAM" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT DISTINCT first_name, last_name FROM contributors'''\n", + "viz_tables(['first_name','last_name'], query)" + ] + }, + { + "cell_type": "markdown", + "id": "7791676e", + "metadata": {}, + "source": [ + "\n", + "# Step 5: Altering Tables\n", + "\n", + "The `ALTER` clause allows us to modify tables in our database. Here, we add a\n", + "new column to our candidates table called `full_name`." + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "6c13962e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_initpartyfull_name
016MikeHuckabeeRNone
120BarackObamaDNone
222RudolphGiulianiRNone
324MikeGravelDNone
426JohnEdwardsDNone
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_init party full_name\n", + "0 16 Mike Huckabee R None\n", + "1 20 Barack Obama D None\n", + "2 22 Rudolph Giuliani R None\n", + "3 24 Mike Gravel D None\n", + "4 26 John Edwards D None" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cursor.execute('''ALTER TABLE candidates ADD COLUMN full_name TEXT''')\n", + "candidate_cols = [col[1] for col in cursor.execute(\"PRAGMA table_info(candidates)\")]\n", + "viz_tables(candidate_cols, '''SELECT * FROM candidates''').head()" + ] + }, + { + "cell_type": "markdown", + "id": "d3447fa1", + "metadata": {}, + "source": [ + "What if we want to rename or delete a column? It can't be done with `SQLite`\n", + "with a single command. We need to follow some roundabout steps (see [`SQLite`\n", + "ALTER TABLE](http://www.sqlitetutorial.net/sqlite-alter-table/)). We won't\n", + "consider this case at the moment." + ] + }, + { + "cell_type": "markdown", + "id": "1596129a", + "metadata": {}, + "source": [ + "For now, let's put a few commands together to populate the `full_name` column." + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "c0787fa6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_initpartyfull_name
016MikeHuckabeeRHuckabee, Mike
120BarackObamaDObama, Barack
222RudolphGiulianiRGiuliani, Rudolph
324MikeGravelDGravel, Mike
426JohnEdwardsDEdwards, John
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_init party full_name\n", + "0 16 Mike Huckabee R Huckabee, Mike\n", + "1 20 Barack Obama D Obama, Barack\n", + "2 22 Rudolph Giuliani R Giuliani, Rudolph\n", + "3 24 Mike Gravel D Gravel, Mike\n", + "4 26 John Edwards D Edwards, John" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "candidate_cols = [col[1] for col in cursor.execute(\"PRAGMA table_info(candidates)\")] # regenerate columns with full_name\n", + "query = '''SELECT id, last_name, first_name FROM candidates''' # Select a few columns\n", + "full_name_and_id = [(attr[1] + \", \" + attr[2], attr[0]) for attr in cursor.execute(query).fetchall()] # List of tuples: (full_name, id)\n", + "\n", + "update = '''UPDATE candidates SET full_name = ? WHERE id = ?''' # Update the table\n", + "for rows in full_name_and_id:\n", + " cursor.execute(update, rows)\n", + "\n", + "query = '''SELECT * FROM candidates'''\n", + "viz_tables(candidate_cols, query).head()" + ] + }, + { + "cell_type": "markdown", + "id": "a0802503", + "metadata": {}, + "source": [ + "Here's another update, this time on an existing column." + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "5c0ff46d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_initpartyfull_name
016MikeHuckabeeRHuckabee, Mike
120BarackObamaDWINNER
222RudolphGiulianiRGiuliani, Rudolph
324MikeGravelDGravel, Mike
426JohnEdwardsDEdwards, John
529BillRichardsonDRichardson, Bill
630DuncanHunterRHunter, Duncan
731DennisKucinichDKucinich, Dennis
832RonPaulRPaul, Ron
933JosephBidenDBiden, Joseph
1034HillaryClintonR.DClinton, Hillary
1135MittRomneyRRomney, Mitt
1236SamuelBrownbackRBrownback, Samuel
1337JohnMcCainRRUNNER-UP
1438TomTancredoRTancredo, Tom
1539ChristopherDoddJ.DDodd, Christopher
1641FredThompsonD.RThompson, Fred
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_init party full_name\n", + "0 16 Mike Huckabee R Huckabee, Mike\n", + "1 20 Barack Obama D WINNER\n", + "2 22 Rudolph Giuliani R Giuliani, Rudolph\n", + "3 24 Mike Gravel D Gravel, Mike\n", + "4 26 John Edwards D Edwards, John\n", + "5 29 Bill Richardson D Richardson, Bill\n", + "6 30 Duncan Hunter R Hunter, Duncan\n", + "7 31 Dennis Kucinich D Kucinich, Dennis\n", + "8 32 Ron Paul R Paul, Ron\n", + "9 33 Joseph Biden D Biden, Joseph\n", + "10 34 Hillary Clinton R. D Clinton, Hillary\n", + "11 35 Mitt Romney R Romney, Mitt\n", + "12 36 Samuel Brownback R Brownback, Samuel\n", + "13 37 John McCain R RUNNER-UP\n", + "14 38 Tom Tancredo R Tancredo, Tom\n", + "15 39 Christopher Dodd J. D Dodd, Christopher\n", + "16 41 Fred Thompson D. R Thompson, Fred" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "update = '''UPDATE candidates SET full_name = \"WINNER\" WHERE last_name = \"Obama\"'''\n", + "cursor.execute(update)\n", + "update = '''UPDATE candidates SET full_name = \"RUNNER-UP\" WHERE last_name = \"McCain\"'''\n", + "cursor.execute(update)\n", + "viz_tables(candidate_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "a1305ad0", + "metadata": {}, + "source": [ + "### Do the following:\n", + "\n", + "* Add a new column to the contributors table called `full_name`. The value in\n", + " that column should be in the form `last_name, first_name`.\n", + "* Change the value in the `full_name` column to the string `\"Too Much\"` if\n", + " someone donated more than $\\$1000.00$." + ] + }, + { + "cell_type": "markdown", + "id": "f0e6c0a7-e6a0-4cf5-8c76-bab1ddd069db", + "metadata": {}, + "source": [ + "#### Add a new column to the contributors table called full_name. The value in that column should be in the form last_name, first_name." + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "84e2a29d-8c1d-40ff-88d8-307e7bea15d0", + "metadata": {}, + "outputs": [], + "source": [ + "cursor.execute('''ALTER TABLE contributors ADD COLUMN full_name TEXT''')\n", + "contributor_cols = [col[1] for col in cursor.execute(\"PRAGMA table_info(contributors)\")]\n" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "23644680-ac7e-4251-97e4-5ca9ff1cc1eb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_idfull_name
01AgeeSteven549 Laurel Branch RoadFloydVA24091500.02007-06-3016None
12AhrensDon4034 Rennellwood WayPleasantonCA94566250.02007-05-1616None
23AhrensDon4034 Rennellwood WayPleasantonCA9456650.02007-06-1816None
34AhrensDon4034 Rennellwood WayPleasantonCA94566100.02007-06-2116None
45AkinCharles10187 Sugar Creek RoadBentonvilleAR72712100.02007-06-1616None
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id full_name\n", + "0 1 Agee Steven 549 Laurel Branch Road Floyd VA 24091 500.0 2007-06-30 16 None\n", + "1 2 Ahrens Don 4034 Rennellwood Way Pleasanton CA 94566 250.0 2007-05-16 16 None\n", + "2 3 Ahrens Don 4034 Rennellwood Way Pleasanton CA 94566 50.0 2007-06-18 16 None\n", + "3 4 Ahrens Don 4034 Rennellwood Way Pleasanton CA 94566 100.0 2007-06-21 16 None\n", + "4 5 Akin Charles 10187 Sugar Creek Road Bentonville AR 72712 100.0 2007-06-16 16 None" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "viz_tables(contributor_cols, '''SELECT * FROM contributors''').head()" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "6a138f78-cfa4-40ca-bf30-3f1376c85826", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_idfull_name
01AgeeSteven549 Laurel Branch RoadFloydVA24091500.02007-06-3016Agee, Steven
12AhrensDon4034 Rennellwood WayPleasantonCA94566250.02007-05-1616Ahrens, Don
23AhrensDon4034 Rennellwood WayPleasantonCA9456650.02007-06-1816Ahrens, Don
34AhrensDon4034 Rennellwood WayPleasantonCA94566100.02007-06-2116Ahrens, Don
45AkinCharles10187 Sugar Creek RoadBentonvilleAR72712100.02007-06-1616Akin, Charles
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id full_name\n", + "0 1 Agee Steven 549 Laurel Branch Road Floyd VA 24091 500.0 2007-06-30 16 Agee, Steven\n", + "1 2 Ahrens Don 4034 Rennellwood Way Pleasanton CA 94566 250.0 2007-05-16 16 Ahrens, Don\n", + "2 3 Ahrens Don 4034 Rennellwood Way Pleasanton CA 94566 50.0 2007-06-18 16 Ahrens, Don\n", + "3 4 Ahrens Don 4034 Rennellwood Way Pleasanton CA 94566 100.0 2007-06-21 16 Ahrens, Don\n", + "4 5 Akin Charles 10187 Sugar Creek Road Bentonville AR 72712 100.0 2007-06-16 16 Akin, Charles" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "contributor_cols = [col[1] for col in cursor.execute(\"PRAGMA table_info(contributors)\")] # regenerate columns with full_name\n", + "query = '''SELECT id, last_name, first_name FROM contributors''' # Select a few columns\n", + "full_name_and_id = [(attr[1] + \", \" + attr[2], attr[0]) for attr in cursor.execute(query).fetchall()] # List of tuples: (full_name, id)\n", + "\n", + "update = '''UPDATE contributors SET full_name = ? WHERE id = ?''' # Update the table\n", + "for rows in full_name_and_id:\n", + " cursor.execute(update, rows)\n", + " \n", + "\n", + "query = '''SELECT * FROM contributors'''\n", + "viz_tables(contributor_cols, query).head()" + ] + }, + { + "cell_type": "markdown", + "id": "1040b4ad-0c56-4cbc-92ce-88eb9b001b9d", + "metadata": {}, + "source": [ + "#### Change the value in the full_name column to the string \"Too Much\" if someone donated more than $1000.00 ." + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "bfba5fe6-7ee6-40f8-ad80-afe9bb35689f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_idfull_name
01AgeeSteven549 Laurel Branch RoadFloydVA24091500.002007-06-3016Agee, Steven
12AhrensDon4034 Rennellwood WayPleasantonCA94566250.002007-05-1616Ahrens, Don
23AhrensDon4034 Rennellwood WayPleasantonCA9456650.002007-06-1816Ahrens, Don
34AhrensDon4034 Rennellwood WayPleasantonCA94566100.002007-06-2116Ahrens, Don
45AkinCharles10187 Sugar Creek RoadBentonvilleAR72712100.002007-06-1616Akin, Charles
56AkinMike181 Baywood LaneMonticelloAR716551500.002007-05-1816Too Much
67AkinRebecca181 Baywood LaneMonticelloAR71655500.002007-05-1816Akin, Rebecca
78AldridgeBrittni808 Capitol Square Place, SWWashingtonDC20024250.002007-06-0616Aldridge, Brittni
89AllenJohn D.1052 Cannon Mill DriveNorth AugustaSC298601000.002007-06-1116Allen, John D.
910AllenJohn D.1052 Cannon Mill DriveNorth AugustaSC298601300.002007-06-2916Too Much
1011AllisonJohn W.P.O. Box 1089ConwayAR720331000.002007-05-1816Allison, John W.
1112AllisonRebecca3206 Summit CourtLittle RockAR722271000.002007-04-2516Allison, Rebecca
1213AllisonRebecca3206 Summit CourtLittle RockAR72227200.002007-06-1216Allison, Rebecca
1314AltesR.D.8600 Moody RoadFort SmithAR729032300.002007-06-2116Too Much
1415AndresDale1160 Glen Oaks DriveWest Des MoinesIA50266250.002007-06-0616Andres, Dale
1516AnthonyJohn211 Long Island DriveHot SpringsAR719132300.002007-06-1216Too Much
1617ArbogastRobert12900 State Route 56 SEMount SterlingOH43143500.002007-04-0816Arbogast, Robert
1718ArbogastRobert12900 State Route 56 SEMount SterlingOH43143100.002007-06-2216Arbogast, Robert
1819ArdleWilliam412 Dakota AvenueSpringfieldOH4550450.002007-06-2816Ardle, William
1920AtiqOmar7200 S Hazel StreetPine BluffAR716031000.002007-05-1816Atiq, Omar
2021AtiqOmar7200 S Hazel StreetPine BluffAR716031000.002007-06-2716Atiq, Omar
2122BakerDavid2550 Adamsbrooke DriveConwayAR720342300.002007-04-1116Too Much
2223BancroftDavid2934 Broderick StreetSan FranciscoCA94123250.002007-04-2416Bancroft, David
2324BanksCharlesP.O. Box 251310Little RockAR722251000.002007-05-1416Banks, Charles
2425BarbeeJohn516 Kellyridge DriveApexNC27502500.002007-05-2316Barbee, John
2526BucklerSteve24351 Armada DrDana PointCA92629130650.002007-07-3020Buckler, Steve
2627BucklerSteve24351 Armada DrDana PointCA92629130625.002007-08-1620Buckler, Steve
2728BuckheitBruce8904 KAREN DRFAIRFAXVA220312731100.002007-09-1920Buckheit, Bruce
2829BuckelLindaPO Box 683130Park CityUT8406831302300.002007-08-1420Too Much
2930BuckelLindaPO Box 683130Park CityUT840683130-2300.002007-08-1420Buckel, Linda
3031BuckelLindaPO Box 683130Park CityUT8406831304600.002007-08-1420Too Much
3132BuckThomas4206 Terrace StreetKansas CityMO64111100.002007-09-2520Buck, Thomas
3233BuckJayK.1855 Old Willow Rd Unit 322NorthfieldIL600932918200.002007-09-1220Buck, Jay
3334BuckBlaineM45 Eaton AveCamdenME0484317522300.002007-09-3020Too Much
3435BuckBarbara1780 NE 138th StNorth MiamiFL33181131650.002007-09-1320Buck, Barbara
3536BuckBarbara1780 NE 138th StNorth MiamiFL33181131650.002007-07-1920Buck, Barbara
3637BuchmanMark M2530 Lawton AveSan Luis ObispoCA934015622460.802007-07-1820Buchman, Mark M
3738BucherIdaM1400 Warnall AveLos AngelesCA900245333100.002007-07-1020Bucher, Ida
3839BuchanekElizabeth7917 Kentbury DrBethesdaMD20814461550.002007-09-3020Buchanek, Elizabeth
3940BuchananJohn2025 NW 29th RdBoca RatonFL334316303500.002007-09-2420Buchanan, John
4041BuchananJohn2025 NW 29th RdBoca RatonFL334316303-500.002007-09-2420Buchanan, John
4142BuchananJohn2025 NW 29th RdBoca RatonFL334316303500.002007-09-2420Buchanan, John
4243BuchananJohn2025 NW 29th RdBoca RatonFL334316303700.002007-08-2820Buchanan, John
4344BuchananJohn2025 NW 29th RdBoca RatonFL334316303-700.002007-08-2820Buchanan, John
4445BuchananJohn2025 NW 29th RdBoca RatonFL3343163031000.002007-08-2820Buchanan, John
4546BuchananJohn2025 NW 29th RdBoca RatonFL3343163031300.002007-08-0920Too Much
4647BuchananJohn2025 NW 29th RdBoca RatonFL334316303200.002007-08-1420Buchanan, John
4748BuchananJohn2025 NW 29th RdBoca RatonFL334316303500.002007-07-2520Buchanan, John
4849BuchananJohn4635 49th St NWWashingtonDC200164320200.092007-09-2320Buchanan, John
4950HarrisonRyan2247 3rd StLa VerneCA91750491825.002007-07-2620Harrison, Ryan
5051BYNUMHERBERT332 SUNNYSIDE ROADTAMPAFL336177249-500.002008-03-1022BYNUM, HERBERT
5152BYINGTONMARGARETE.2633 MIDDLEBORO LANE N.E.GRAND RAPIDSMI495061254-2300.002008-03-0322BYINGTON, MARGARET
5253BYERSBOBA.13170 TELFAIR AVENUESYLMARCA913423573-2300.002008-03-0722BYERS, BOB
5354BYERSAUDREY2658 LADBROOK WAYTHOUSAND OAKSCA913615073-200.002008-03-0722BYERS, AUDREY
5455BUSHKRYSTIEP.O. BOX 61046DENVERCO802061046-2300.002008-03-0622BUSH, KRYSTIE
5556BUSHERICP.O. BOX 61046DENVERCO802061046-2300.002008-03-0622BUSH, ERIC
5657BURTONSUSAN9338 DEER CREEK DRIVETAMPAFL336472286-2300.002008-03-0522BURTON, SUSAN
5758BURTONSTEVENG.9938 DEER CREEK DRIVETAMPAFL33647-2300.002008-03-0522BURTON, STEVEN
5859BURTONGLENNM.4404 CHARLESTON COURTTAMPAFL336092620-2300.002008-03-0522BURTON, GLENN
5960BURKHARDTCRAIGS.910 15TH STREET N.W.WASHINGTONDC200052503-500.002008-03-0722BURKHARDT, CRAIG
6061BURKHARDTCRAIGS.910 15TH STREET N.W.WASHINGTONDC200052503-1000.002008-03-0722BURKHARDT, CRAIG
6162BURKHARDTBARBARA910 15TH STREET N.W.WASHINGTONDC200052503-500.002008-03-0722BURKHARDT, BARBARA
6263BURKESUZANNEM.3401 EVANSTONSEATTLEWA981038677-700.002008-03-0522BURKE, SUZANNE
6364BURKEGAIL165 E. 32ND STREETAPARTMENT 9ENEW YORKNY100166014-2000.002008-03-0522BURKE, GAIL
6465BURKEDONALDJ.12 LOMPOCRANCHO SANTA MARGACA926881817-2300.002008-03-1122BURKE, DONALD
6566BURGERTRONALDL.5723 PLUMTREE DRIVEDALLASTX752524926-1000.002008-03-0522BURGERT, RONALD
6667BULLBARTLEB.439 E. 51ST STREETNEW YORKNY100226473-800.002008-03-1022BULL, BARTLE
6768BULLBARTLEB.439 E. 51ST STREETNEW YORKNY100226473-1000.002008-03-1022BULL, BARTLE
6869BUKOWSKIDANIELJ.702 S. WRIGHT STREETNAPERVILLEIL605406736-100.002008-03-1022BUKOWSKI, DANIEL
6970BUISSONMARGARETA.P.O. BOX 197029LOUISVILLEKY402597029-200.002008-03-1122BUISSON, MARGARET
7071BUCKLEYWALTERW.1635 COUNTRY ROADBETHLEHEMPA180155718-100.002008-03-0522BUCKLEY, WALTER
7172BUCKLEYMARJORIEB.1635 COUNTRY ROADBETHLEHEMPA180155718-100.002008-03-0522BUCKLEY, MARJORIE
7273BRUNOJOHN10136 WINDERMERE CHASE BLVD.GOTHAFL347344707-2300.002008-03-0622BRUNO, JOHN
7374BRUNOIRENE10136 WINDERMERE CHASE BLVD.GOTHAFL347344707-2300.002008-03-0622BRUNO, IRENE
7475BROWNTIMOTHYJ.26826 MARLOWE COURTSTEVENSON RANCHCA913811020-2300.002008-03-0622BROWN, TIMOTHY
7576SchuffBryan1700 W Sweden RdBrockportNY14420-25.002008-08-2232Schuff, Bryan
7677HobbsJames229 Cherry LaneWhite HouseTN37188-25.002008-08-1932Hobbs, James
7778RanganathAnoop2507 Willard DriveCharlottesvilleVA22903-100.002008-04-2132Ranganath, Anoop
7879NystromMichaelA93A Fairmont StreetArlingtonMA02474-503.002008-04-2132Nystrom, Michael
7980MuseNinaJo2915 Toro Canyon RdAustinTX78746-50.002008-04-2132Muse, Nina
8081WaddellJamesL.1823 Spel Lane SWRochesterMN55902-28.002008-04-2132Waddell, James
8182BrucksWilliamC.PO Box 391Corona del MarCA92625-150.002008-04-2132Brucks, William
8283KuehnDavid14502 West 93rd StreetLenexaKS66215-330.002008-04-2132Kuehn, David
8384VersterJeanetteM.7220 SW 61st StMiamiFL331431807-1000.002008-04-2132Verster, Jeanette
8485UihleinRichard1396 N Waukegan RdLake ForestIL600451147-2300.002008-04-2132Uihlein, Richard
8586EskenberryRobertP10960 Gray CirWestminsterCO80020-223.002008-04-2132Eskenberry, Robert
8687FroehlingAlanL.302 Broadway StMount VernonIL628645116-844.802008-04-2132Froehling, Alan
8788DuryeaMarciaA.123 Bayview AveAmityvilleNY11701-299.502008-04-2132Duryea, Marcia
8889PerreaultLouise503 Brockridge Hunt DriveHamptonVA23666-34.082008-04-2132Perreault, Louise
8990RozenfeldTimur57 Herbert RoadRobbinsvilleNJ08691-777.952008-04-2132Rozenfeld, Timur
9091KazorChristopherM707 Spindletree aveNapervilleIL60565-2592.002008-04-2132Kazor, Christopher
9192LehnerThomasS.2701 Star LaneWadsworthOH44281-200.002008-04-2132Lehner, Thomas
9293PlummerJoseph587 Blake Hill RdNew HamptonNH032564424-24.602008-04-2132Plummer, Joseph
9394RaughtPhilipM4714 Plum WayPittsburghPA15201-1046.002008-04-2132Raught, Philip
9495FerraraJudithD1508 Waterford RoadYardleyPA19067-1100.002008-04-2132Ferrara, Judith
9596JohnsonCathleenE.1003 Justin Ln Apt 2016AustinTX787572648-14.762008-04-2132Johnson, Cathleen
9697SanfordBradley940 Post St #43San FranciscoCA94109-24.532008-04-2132Sanford, Bradley
9798GaarderBrucePO Box 4085Mountain Home AFBID83648-261.002008-04-2132Gaarder, Bruce
9899ChoeHyeokchan207 Bridle WayFort LeeNJ070246302-39.502008-04-2132Choe, Hyeokchan
99100JacobsRichardG.14337 Tawya RdApple ValleyCA923075545-1000.002008-04-2132Jacobs, Richard
100101AaronsonRebecca2000 Village Green Dr Apt 12Mill CreekWA980125787100.002008-02-0834Aaronson, Rebecca
101102AaronsElaine481 Buck Island Rd Apt 17AAPT 17AWest YarmouthMA02673330025.002008-02-2634Aarons, Elaine
102103AaronsElaine481 Buck Island Rd Apt 17AAPT 17AWest YarmouthMA02673330070.002008-02-2534Aarons, Elaine
103104AaronsElaine481 Buck Island Rd Apt 17AAPT 17AWest YarmouthMA026733300100.002008-02-0834Aarons, Elaine
104105AaronShirley101 Cherry AveHavanaFL32333131150.002008-02-2934Aaron, Shirley
105106AaronShirley101 Cherry AveHavanaFL323331311100.002008-02-2934Aaron, Shirley
106107AaronsonRebecca2000 Village Green Dr Apt 12Mill CreekWA980125787100.002008-02-1434Aaronson, Rebecca
107108AaronShirley101 Cherry AveHavanaFL323331311100.002008-02-2434Aaron, Shirley
108109AaronShirley101 Cherry AveHavanaFL323331311100.002008-02-2234Aaron, Shirley
109110AaronShirley101 Cherry AveHavanaFL323331311100.002008-02-1734Aaron, Shirley
110111ReidElizabeth73 W Patent RdOPHIR FARM NORTHBedford HillsNY105072222-350.002008-08-2834Reid, Elizabeth
111112ReichThomas499 Park AveNew YorkNY100221240-2300.002008-08-2834Reich, Thomas
112113AaronShirley101 Cherry AveHavanaFL323331311100.002008-02-0834Aaron, Shirley
113114AaronShirley101 Cherry AveHavanaFL323331311100.002008-02-0334Aaron, Shirley
114115AaronSharron1804 E Montgomery StBroken ArrowOK740121840500.002008-02-0934Aaron, Sharron
115116AaronPatricia418 NW 35th StOklahoma CityOK731188602200.002008-02-2634Aaron, Patricia
116117AaronPatricia418 NW 35th StOklahoma CityOK731188602100.002008-02-1234Aaron, Patricia
117118AaronJim2178 Fairway CirCantonMI481885097300.002008-02-0734Aaron, Jim
118119AaronJim2178 Fairway CirCantonMI481885097200.002008-02-2934Aaron, Jim
119120AaronCarolePO Box 1806OgunquitME03907180670.002008-02-2934Aaron, Carole
120121AaronCarolePO Box 1806OgunquitME03907180650.002008-02-0734Aaron, Carole
121122AaronCarolePO Box 1806OgunquitME039071806100.002008-02-0334Aaron, Carole
122123AaronBarbara2298 Pacific Ave # 6San FranciscoCA9411514351000.002008-02-1134Aaron, Barbara
123124AanonsenLin897 Raymond AveSaint PaulMN551141508250.002008-02-2134Aanonsen, Lin
124125AanonsenLin897 Raymond AveSaint PaulMN551141508100.002008-02-0834Aanonsen, Lin
125126BOURNETRAVISLAGE KAART 77BRASSCHATT02930-500.002008-11-2035BOURNE, TRAVIS
126127SECRISTBRIANL.3 MULE DEER TRAILLITTLETONCO801275722-1000.002008-04-0735SECRIST, BRIAN
127128TOLLESTRUPTRAVISW.16331 WINECREEK RD.SAN DIEGOCA92127-1000.002008-05-1535TOLLESTRUP, TRAVIS
128129ACCORDDEANC.8813 ROBINSON RIDGE ROADLAS VEGASNV891175812500.002007-07-1335ACCORD, DEAN
129130ABTSHENRYP. O. BOX 7299INCLINE VILLAGENV894527299100.002007-07-1335ABTS, HENRY
130131ABSHIERLANNY14191 S.E. HIGHWAY 301SUMMERFIELDFL34491500.002007-09-2535ABSHIER, LANNY
131132ABSHIERDIANA14191 S.E. HIGHWAY 301SUMMERFIELDFL34491500.002007-09-2535ABSHIER, DIANA
132133ABREUKEVINM.1305 GARDEN GLEN LANEPEARLANDTX77581654750.002007-09-3035ABREU, KEVIN
133134ABREUKEVINM.1305 GARDEN GLEN LANEPEARLANDTX775816547150.002007-08-0935ABREU, KEVIN
134135ABREUKEVINM.1305 GARDEN GLEN LANEPEARLANDTX77581654750.002007-07-1935ABREU, KEVIN
135136ABRAMOWITZNIRA411 HARBOR ROADSOUTHPORTCT0689013762300.002007-09-1435Too Much
136137ABRAMSMICHAEL7910 WOODMONT AVENUEBETHESDAMD208143002250.002007-09-2935ABRAMS, MICHAEL
137138ABRAMOWITZKEN200 CENTRAL PARK S.APARTMENT 31ANEW YORKNY100191448300.002007-09-1135ABRAMOWITZ, KEN
138139ABOUBAKARENASAR1400 SAN MIGUEL DRIVECORONA DEL MARCA9262513001000.002007-07-0935ABOUBAKARE, NASAR
139140ABEGGPATRICIAT.1862 E. 5150 S.SALT LAKE CITYUT84117691175.002007-09-2535ABEGG, PATRICIA
140141ABEGGPATRICIAT.1862 E. 5150 S.SALT LAKE CITYUT84117691125.002007-09-1735ABEGG, PATRICIA
141142ABEGGPATRICIAT.1862 E. 5150 S.SALT LAKE CITYUT84117691175.002007-08-3135ABEGG, PATRICIA
142143ABEGGPATRICIAT.1862 E. 5150 S.SALT LAKE CITYUT84117691175.002007-08-1435ABEGG, PATRICIA
143144ABEGGPATRICIAT.1862 E. 5150 S.SALT LAKE CITYUT84117691125.002007-08-0635ABEGG, PATRICIA
144145ABEGGPATRICIAT.1862 E. 5150 S.SALT LAKE CITYUT84117691125.002007-07-1035ABEGG, PATRICIA
145146ABDELLATHOMASM.4231 MONUMENT WALL WAY #340FAIRFAXVA22030844050.002007-09-3035ABDELLA, THOMAS
146147ABBOTTWELDONS.777 EAST SOUTH TEMPLE 4ESALT LAKE CITYUT841021269100.002007-09-2935ABBOTT, WELDON
147148ABBOTTWELDONS.777 EAST SOUTH TEMPLE 4ESALT LAKE CITYUT84102126950.002007-08-0935ABBOTT, WELDON
148149ABBOTTGERALDF.389 BENEFIT STREETPROVIDENCERI029032946100.002007-09-1535ABBOTT, GERALD
149150ABBOTTGERALDF.389 BENEFIT STREETPROVIDENCERI029032946100.002007-08-1535ABBOTT, GERALD
150151ABEDINZAINUL715 N. CENTRAL AVENUESUITE 212GLENDALECA912031164500.002008-01-2137ABEDIN, ZAINUL
151152ABBOTTSYBILF.446 GAMES DRIVERENONV89509332675.002008-01-0837ABBOTT, SYBIL
152153ABBOTTSYBILF.446 GAMES DRIVERENONV89509332650.002008-01-0837ABBOTT, SYBIL
153154ABBOTTRONALDLEANDER5453 HAWTHORNE STREETMONTCLAIRCA917632551200.002008-01-3137ABBOTT, RONALD
154155ABBOTTRONALDLEANDER5453 HAWTHORNE STREETMONTCLAIRCA917632551100.002008-01-0837ABBOTT, RONALD
155156ABBOTTROBERTA.3061 LOREE ROADDECKERVILLEMI484279763500.002008-01-2137ABBOTT, ROBERT
156157ABBOTTMIKEE.4516 OSPREY LNDGNICEVILLEFL3257868101000.002008-01-1537ABBOTT, MIKE
157158ABBOTDAVIDM.56 SALEM STREETANDOVERMA018102114200.002008-01-2137ABBOT, DAVID
158159ABBOPAULINEMORENCY10720 JACOB LANEWHITE LAKEMI48386227435.002008-01-0737ABBO, PAULINE
159160ABATEMARIAELENA1291 NIGHTINGALE AVENUEMIAMI SPRINGSFL3316638322600.002008-01-2537Too Much
160161ABAIRPETER40 EVANS STREETWATERTOWNMA02472215025.002008-01-0937ABAIR, PETER
161162ABACHERLISHIRLEYM.29875 NEWPORT ROADMENIFEECA925849524150.002008-01-2837ABACHERLI, SHIRLEY
162163AARONSCHARLES1730 SHORE DRIVEANCHORAGEAK995153207300.002008-01-3037AARONS, CHARLES
163164AARONSCHARLES1730 SHORE DRIVEANCHORAGEAK995153207410.002008-01-1537AARONS, CHARLES
164165AARONSCHARLES1730 SHORE DRIVEANCHORAGEAK995153207500.002008-01-0937AARONS, CHARLES
165166ABELJOHNH.422 THOMAS STREETBETHLEHEMPA180153316200.002008-01-2237ABEL, JOHN
166167ABELMARLINGL.14 HANGING MOSS LANEGREENVILLESC296155069100.002008-01-2237ABEL, MARLING
167168ABELRUDOLPH4532 OCEAN BLVD.# 108SARASOTAFL342421337100.002008-01-0837ABEL, RUDOLPH
168169ABELERODNEY3620 METAIRIE HEIGHTS AVENUEMETAIRIELA700021823500.002008-01-1537ABELE, RODNEY
169170ABERCROMBIEDENIS11811 WATER OAK CTMAGNOLIATX773546270500.002008-01-3037ABERCROMBIE, DENIS
170171ABESHAUSMERRILLM.1801 N. HEREFORD DRIVEFLAGSTAFFAZ860011121120.002008-01-1637ABESHAUS, MERRILL
171172ABRAHAMGEORGEP.O. BOX 1504LAKE CHARLESLA706021504800.002008-01-1737ABRAHAM, GEORGE
172173ABRAHAMSONPETERJ.1030 W. ROSCOE STREETCHICAGOIL60657220750.002008-01-2537ABRAHAMSON, PETER
173174ABRAHAMSALEMA.P.O. BOX 7CANADIANTX7901400071000.002008-01-1737ABRAHAM, SALEM
174175ABRAHAMSALEMA.P.O. BOX 7CANADIANTX7901400071300.002008-01-3037Too Much
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id full_name\n", + "0 1 Agee Steven 549 Laurel Branch Road Floyd VA 24091 500.00 2007-06-30 16 Agee, Steven\n", + "1 2 Ahrens Don 4034 Rennellwood Way Pleasanton CA 94566 250.00 2007-05-16 16 Ahrens, Don\n", + "2 3 Ahrens Don 4034 Rennellwood Way Pleasanton CA 94566 50.00 2007-06-18 16 Ahrens, Don\n", + "3 4 Ahrens Don 4034 Rennellwood Way Pleasanton CA 94566 100.00 2007-06-21 16 Ahrens, Don\n", + "4 5 Akin Charles 10187 Sugar Creek Road Bentonville AR 72712 100.00 2007-06-16 16 Akin, Charles\n", + "5 6 Akin Mike 181 Baywood Lane Monticello AR 71655 1500.00 2007-05-18 16 Too Much\n", + "6 7 Akin Rebecca 181 Baywood Lane Monticello AR 71655 500.00 2007-05-18 16 Akin, Rebecca\n", + "7 8 Aldridge Brittni 808 Capitol Square Place, SW Washington DC 20024 250.00 2007-06-06 16 Aldridge, Brittni\n", + "8 9 Allen John D. 1052 Cannon Mill Drive North Augusta SC 29860 1000.00 2007-06-11 16 Allen, John D.\n", + "9 10 Allen John D. 1052 Cannon Mill Drive North Augusta SC 29860 1300.00 2007-06-29 16 Too Much\n", + "10 11 Allison John W. P.O. Box 1089 Conway AR 72033 1000.00 2007-05-18 16 Allison, John W.\n", + "11 12 Allison Rebecca 3206 Summit Court Little Rock AR 72227 1000.00 2007-04-25 16 Allison, Rebecca\n", + "12 13 Allison Rebecca 3206 Summit Court Little Rock AR 72227 200.00 2007-06-12 16 Allison, Rebecca\n", + "13 14 Altes R.D. 8600 Moody Road Fort Smith AR 72903 2300.00 2007-06-21 16 Too Much\n", + "14 15 Andres Dale 1160 Glen Oaks Drive West Des Moines IA 50266 250.00 2007-06-06 16 Andres, Dale\n", + "15 16 Anthony John 211 Long Island Drive Hot Springs AR 71913 2300.00 2007-06-12 16 Too Much\n", + "16 17 Arbogast Robert 12900 State Route 56 SE Mount Sterling OH 43143 500.00 2007-04-08 16 Arbogast, Robert\n", + "17 18 Arbogast Robert 12900 State Route 56 SE Mount Sterling OH 43143 100.00 2007-06-22 16 Arbogast, Robert\n", + "18 19 Ardle William 412 Dakota Avenue Springfield OH 45504 50.00 2007-06-28 16 Ardle, William\n", + "19 20 Atiq Omar 7200 S Hazel Street Pine Bluff AR 71603 1000.00 2007-05-18 16 Atiq, Omar\n", + "20 21 Atiq Omar 7200 S Hazel Street Pine Bluff AR 71603 1000.00 2007-06-27 16 Atiq, Omar\n", + "21 22 Baker David 2550 Adamsbrooke Drive Conway AR 72034 2300.00 2007-04-11 16 Too Much\n", + "22 23 Bancroft David 2934 Broderick Street San Francisco CA 94123 250.00 2007-04-24 16 Bancroft, David\n", + "23 24 Banks Charles P.O. Box 251310 Little Rock AR 72225 1000.00 2007-05-14 16 Banks, Charles\n", + "24 25 Barbee John 516 Kellyridge Drive Apex NC 27502 500.00 2007-05-23 16 Barbee, John\n", + "25 26 Buckler Steve 24351 Armada Dr Dana Point CA 926291306 50.00 2007-07-30 20 Buckler, Steve\n", + "26 27 Buckler Steve 24351 Armada Dr Dana Point CA 926291306 25.00 2007-08-16 20 Buckler, Steve\n", + "27 28 Buckheit Bruce 8904 KAREN DR FAIRFAX VA 220312731 100.00 2007-09-19 20 Buckheit, Bruce\n", + "28 29 Buckel Linda PO Box 683130 Park City UT 840683130 2300.00 2007-08-14 20 Too Much\n", + "29 30 Buckel Linda PO Box 683130 Park City UT 840683130 -2300.00 2007-08-14 20 Buckel, Linda\n", + "30 31 Buckel Linda PO Box 683130 Park City UT 840683130 4600.00 2007-08-14 20 Too Much\n", + "31 32 Buck Thomas 4206 Terrace Street Kansas City MO 64111 100.00 2007-09-25 20 Buck, Thomas\n", + "32 33 Buck Jay K. 1855 Old Willow Rd Unit 322 Northfield IL 600932918 200.00 2007-09-12 20 Buck, Jay\n", + "33 34 Buck Blaine M 45 Eaton Ave Camden ME 048431752 2300.00 2007-09-30 20 Too Much\n", + "34 35 Buck Barbara 1780 NE 138th St North Miami FL 331811316 50.00 2007-09-13 20 Buck, Barbara\n", + "35 36 Buck Barbara 1780 NE 138th St North Miami FL 331811316 50.00 2007-07-19 20 Buck, Barbara\n", + "36 37 Buchman Mark M 2530 Lawton Ave San Luis Obispo CA 934015622 460.80 2007-07-18 20 Buchman, Mark M\n", + "37 38 Bucher Ida M 1400 Warnall Ave Los Angeles CA 900245333 100.00 2007-07-10 20 Bucher, Ida\n", + "38 39 Buchanek Elizabeth 7917 Kentbury Dr Bethesda MD 208144615 50.00 2007-09-30 20 Buchanek, Elizabeth\n", + "39 40 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 500.00 2007-09-24 20 Buchanan, John\n", + "40 41 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 -500.00 2007-09-24 20 Buchanan, John\n", + "41 42 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 500.00 2007-09-24 20 Buchanan, John\n", + "42 43 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 700.00 2007-08-28 20 Buchanan, John\n", + "43 44 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 -700.00 2007-08-28 20 Buchanan, John\n", + "44 45 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 1000.00 2007-08-28 20 Buchanan, John\n", + "45 46 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 1300.00 2007-08-09 20 Too Much\n", + "46 47 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 200.00 2007-08-14 20 Buchanan, John\n", + "47 48 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 500.00 2007-07-25 20 Buchanan, John\n", + "48 49 Buchanan John 4635 49th St NW Washington DC 200164320 200.09 2007-09-23 20 Buchanan, John\n", + "49 50 Harrison Ryan 2247 3rd St La Verne CA 917504918 25.00 2007-07-26 20 Harrison, Ryan\n", + "50 51 BYNUM HERBERT 332 SUNNYSIDE ROAD TAMPA FL 336177249 -500.00 2008-03-10 22 BYNUM, HERBERT\n", + "51 52 BYINGTON MARGARET E. 2633 MIDDLEBORO LANE N.E. GRAND RAPIDS MI 495061254 -2300.00 2008-03-03 22 BYINGTON, MARGARET\n", + "52 53 BYERS BOB A. 13170 TELFAIR AVENUE SYLMAR CA 913423573 -2300.00 2008-03-07 22 BYERS, BOB\n", + "53 54 BYERS AUDREY 2658 LADBROOK WAY THOUSAND OAKS CA 913615073 -200.00 2008-03-07 22 BYERS, AUDREY\n", + "54 55 BUSH KRYSTIE P.O. BOX 61046 DENVER CO 802061046 -2300.00 2008-03-06 22 BUSH, KRYSTIE\n", + "55 56 BUSH ERIC P.O. BOX 61046 DENVER CO 802061046 -2300.00 2008-03-06 22 BUSH, ERIC\n", + "56 57 BURTON SUSAN 9338 DEER CREEK DRIVE TAMPA FL 336472286 -2300.00 2008-03-05 22 BURTON, SUSAN\n", + "57 58 BURTON STEVEN G. 9938 DEER CREEK DRIVE TAMPA FL 33647 -2300.00 2008-03-05 22 BURTON, STEVEN\n", + "58 59 BURTON GLENN M. 4404 CHARLESTON COURT TAMPA FL 336092620 -2300.00 2008-03-05 22 BURTON, GLENN\n", + "59 60 BURKHARDT CRAIG S. 910 15TH STREET N.W. WASHINGTON DC 200052503 -500.00 2008-03-07 22 BURKHARDT, CRAIG\n", + "60 61 BURKHARDT CRAIG S. 910 15TH STREET N.W. WASHINGTON DC 200052503 -1000.00 2008-03-07 22 BURKHARDT, CRAIG\n", + "61 62 BURKHARDT BARBARA 910 15TH STREET N.W. WASHINGTON DC 200052503 -500.00 2008-03-07 22 BURKHARDT, BARBARA\n", + "62 63 BURKE SUZANNE M. 3401 EVANSTON SEATTLE WA 981038677 -700.00 2008-03-05 22 BURKE, SUZANNE\n", + "63 64 BURKE GAIL 165 E. 32ND STREET APARTMENT 9E NEW YORK NY 100166014 -2000.00 2008-03-05 22 BURKE, GAIL\n", + "64 65 BURKE DONALD J. 12 LOMPOC RANCHO SANTA MARGA CA 926881817 -2300.00 2008-03-11 22 BURKE, DONALD\n", + "65 66 BURGERT RONALD L. 5723 PLUMTREE DRIVE DALLAS TX 752524926 -1000.00 2008-03-05 22 BURGERT, RONALD\n", + "66 67 BULL BARTLE B. 439 E. 51ST STREET NEW YORK NY 100226473 -800.00 2008-03-10 22 BULL, BARTLE\n", + "67 68 BULL BARTLE B. 439 E. 51ST STREET NEW YORK NY 100226473 -1000.00 2008-03-10 22 BULL, BARTLE\n", + "68 69 BUKOWSKI DANIEL J. 702 S. WRIGHT STREET NAPERVILLE IL 605406736 -100.00 2008-03-10 22 BUKOWSKI, DANIEL\n", + "69 70 BUISSON MARGARET A. P.O. BOX 197029 LOUISVILLE KY 402597029 -200.00 2008-03-11 22 BUISSON, MARGARET\n", + "70 71 BUCKLEY WALTER W. 1635 COUNTRY ROAD BETHLEHEM PA 180155718 -100.00 2008-03-05 22 BUCKLEY, WALTER\n", + "71 72 BUCKLEY MARJORIE B. 1635 COUNTRY ROAD BETHLEHEM PA 180155718 -100.00 2008-03-05 22 BUCKLEY, MARJORIE\n", + "72 73 BRUNO JOHN 10136 WINDERMERE CHASE BLVD. GOTHA FL 347344707 -2300.00 2008-03-06 22 BRUNO, JOHN\n", + "73 74 BRUNO IRENE 10136 WINDERMERE CHASE BLVD. GOTHA FL 347344707 -2300.00 2008-03-06 22 BRUNO, IRENE\n", + "74 75 BROWN TIMOTHY J. 26826 MARLOWE COURT STEVENSON RANCH CA 913811020 -2300.00 2008-03-06 22 BROWN, TIMOTHY\n", + "75 76 Schuff Bryan 1700 W Sweden Rd Brockport NY 14420 -25.00 2008-08-22 32 Schuff, Bryan\n", + "76 77 Hobbs James 229 Cherry Lane White House TN 37188 -25.00 2008-08-19 32 Hobbs, James\n", + "77 78 Ranganath Anoop 2507 Willard Drive Charlottesville VA 22903 -100.00 2008-04-21 32 Ranganath, Anoop\n", + "78 79 Nystrom Michael A 93A Fairmont Street Arlington MA 02474 -503.00 2008-04-21 32 Nystrom, Michael\n", + "79 80 Muse Nina Jo 2915 Toro Canyon Rd Austin TX 78746 -50.00 2008-04-21 32 Muse, Nina\n", + "80 81 Waddell James L. 1823 Spel Lane SW Rochester MN 55902 -28.00 2008-04-21 32 Waddell, James\n", + "81 82 Brucks William C. PO Box 391 Corona del Mar CA 92625 -150.00 2008-04-21 32 Brucks, William\n", + "82 83 Kuehn David 14502 West 93rd Street Lenexa KS 66215 -330.00 2008-04-21 32 Kuehn, David\n", + "83 84 Verster Jeanette M. 7220 SW 61st St Miami FL 331431807 -1000.00 2008-04-21 32 Verster, Jeanette\n", + "84 85 Uihlein Richard 1396 N Waukegan Rd Lake Forest IL 600451147 -2300.00 2008-04-21 32 Uihlein, Richard\n", + "85 86 Eskenberry Robert P 10960 Gray Cir Westminster CO 80020 -223.00 2008-04-21 32 Eskenberry, Robert\n", + "86 87 Froehling Alan L. 302 Broadway St Mount Vernon IL 628645116 -844.80 2008-04-21 32 Froehling, Alan\n", + "87 88 Duryea Marcia A. 123 Bayview Ave Amityville NY 11701 -299.50 2008-04-21 32 Duryea, Marcia\n", + "88 89 Perreault Louise 503 Brockridge Hunt Drive Hampton VA 23666 -34.08 2008-04-21 32 Perreault, Louise\n", + "89 90 Rozenfeld Timur 57 Herbert Road Robbinsville NJ 08691 -777.95 2008-04-21 32 Rozenfeld, Timur\n", + "90 91 Kazor Christopher M 707 Spindletree ave Naperville IL 60565 -2592.00 2008-04-21 32 Kazor, Christopher\n", + "91 92 Lehner Thomas S. 2701 Star Lane Wadsworth OH 44281 -200.00 2008-04-21 32 Lehner, Thomas\n", + "92 93 Plummer Joseph 587 Blake Hill Rd New Hampton NH 032564424 -24.60 2008-04-21 32 Plummer, Joseph\n", + "93 94 Raught Philip M 4714 Plum Way Pittsburgh PA 15201 -1046.00 2008-04-21 32 Raught, Philip\n", + "94 95 Ferrara Judith D 1508 Waterford Road Yardley PA 19067 -1100.00 2008-04-21 32 Ferrara, Judith\n", + "95 96 Johnson Cathleen E. 1003 Justin Ln Apt 2016 Austin TX 787572648 -14.76 2008-04-21 32 Johnson, Cathleen\n", + "96 97 Sanford Bradley 940 Post St #43 San Francisco CA 94109 -24.53 2008-04-21 32 Sanford, Bradley\n", + "97 98 Gaarder Bruce PO Box 4085 Mountain Home AFB ID 83648 -261.00 2008-04-21 32 Gaarder, Bruce\n", + "98 99 Choe Hyeokchan 207 Bridle Way Fort Lee NJ 070246302 -39.50 2008-04-21 32 Choe, Hyeokchan\n", + "99 100 Jacobs Richard G. 14337 Tawya Rd Apple Valley CA 923075545 -1000.00 2008-04-21 32 Jacobs, Richard\n", + "100 101 Aaronson Rebecca 2000 Village Green Dr Apt 12 Mill Creek WA 980125787 100.00 2008-02-08 34 Aaronson, Rebecca\n", + "101 102 Aarons Elaine 481 Buck Island Rd Apt 17A APT 17A West Yarmouth MA 026733300 25.00 2008-02-26 34 Aarons, Elaine\n", + "102 103 Aarons Elaine 481 Buck Island Rd Apt 17A APT 17A West Yarmouth MA 026733300 70.00 2008-02-25 34 Aarons, Elaine\n", + "103 104 Aarons Elaine 481 Buck Island Rd Apt 17A APT 17A West Yarmouth MA 026733300 100.00 2008-02-08 34 Aarons, Elaine\n", + "104 105 Aaron Shirley 101 Cherry Ave Havana FL 323331311 50.00 2008-02-29 34 Aaron, Shirley\n", + "105 106 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.00 2008-02-29 34 Aaron, Shirley\n", + "106 107 Aaronson Rebecca 2000 Village Green Dr Apt 12 Mill Creek WA 980125787 100.00 2008-02-14 34 Aaronson, Rebecca\n", + "107 108 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.00 2008-02-24 34 Aaron, Shirley\n", + "108 109 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.00 2008-02-22 34 Aaron, Shirley\n", + "109 110 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.00 2008-02-17 34 Aaron, Shirley\n", + "110 111 Reid Elizabeth 73 W Patent Rd OPHIR FARM NORTH Bedford Hills NY 105072222 -350.00 2008-08-28 34 Reid, Elizabeth\n", + "111 112 Reich Thomas 499 Park Ave New York NY 100221240 -2300.00 2008-08-28 34 Reich, Thomas\n", + "112 113 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.00 2008-02-08 34 Aaron, Shirley\n", + "113 114 Aaron Shirley 101 Cherry Ave Havana FL 323331311 100.00 2008-02-03 34 Aaron, Shirley\n", + "114 115 Aaron Sharron 1804 E Montgomery St Broken Arrow OK 740121840 500.00 2008-02-09 34 Aaron, Sharron\n", + "115 116 Aaron Patricia 418 NW 35th St Oklahoma City OK 731188602 200.00 2008-02-26 34 Aaron, Patricia\n", + "116 117 Aaron Patricia 418 NW 35th St Oklahoma City OK 731188602 100.00 2008-02-12 34 Aaron, Patricia\n", + "117 118 Aaron Jim 2178 Fairway Cir Canton MI 481885097 300.00 2008-02-07 34 Aaron, Jim\n", + "118 119 Aaron Jim 2178 Fairway Cir Canton MI 481885097 200.00 2008-02-29 34 Aaron, Jim\n", + "119 120 Aaron Carole PO Box 1806 Ogunquit ME 039071806 70.00 2008-02-29 34 Aaron, Carole\n", + "120 121 Aaron Carole PO Box 1806 Ogunquit ME 039071806 50.00 2008-02-07 34 Aaron, Carole\n", + "121 122 Aaron Carole PO Box 1806 Ogunquit ME 039071806 100.00 2008-02-03 34 Aaron, Carole\n", + "122 123 Aaron Barbara 2298 Pacific Ave # 6 San Francisco CA 941151435 1000.00 2008-02-11 34 Aaron, Barbara\n", + "123 124 Aanonsen Lin 897 Raymond Ave Saint Paul MN 551141508 250.00 2008-02-21 34 Aanonsen, Lin\n", + "124 125 Aanonsen Lin 897 Raymond Ave Saint Paul MN 551141508 100.00 2008-02-08 34 Aanonsen, Lin\n", + "125 126 BOURNE TRAVIS LAGE KAART 77 BRASSCHATT 02930 -500.00 2008-11-20 35 BOURNE, TRAVIS\n", + "126 127 SECRIST BRIAN L. 3 MULE DEER TRAIL LITTLETON CO 801275722 -1000.00 2008-04-07 35 SECRIST, BRIAN\n", + "127 128 TOLLESTRUP TRAVIS W. 16331 WINECREEK RD. SAN DIEGO CA 92127 -1000.00 2008-05-15 35 TOLLESTRUP, TRAVIS\n", + "128 129 ACCORD DEAN C. 8813 ROBINSON RIDGE ROAD LAS VEGAS NV 891175812 500.00 2007-07-13 35 ACCORD, DEAN\n", + "129 130 ABTS HENRY P. O. BOX 7299 INCLINE VILLAGE NV 894527299 100.00 2007-07-13 35 ABTS, HENRY\n", + "130 131 ABSHIER LANNY 14191 S.E. HIGHWAY 301 SUMMERFIELD FL 34491 500.00 2007-09-25 35 ABSHIER, LANNY\n", + "131 132 ABSHIER DIANA 14191 S.E. HIGHWAY 301 SUMMERFIELD FL 34491 500.00 2007-09-25 35 ABSHIER, DIANA\n", + "132 133 ABREU KEVIN M. 1305 GARDEN GLEN LANE PEARLAND TX 775816547 50.00 2007-09-30 35 ABREU, KEVIN\n", + "133 134 ABREU KEVIN M. 1305 GARDEN GLEN LANE PEARLAND TX 775816547 150.00 2007-08-09 35 ABREU, KEVIN\n", + "134 135 ABREU KEVIN M. 1305 GARDEN GLEN LANE PEARLAND TX 775816547 50.00 2007-07-19 35 ABREU, KEVIN\n", + "135 136 ABRAMOWITZ NIRA 411 HARBOR ROAD SOUTHPORT CT 068901376 2300.00 2007-09-14 35 Too Much\n", + "136 137 ABRAMS MICHAEL 7910 WOODMONT AVENUE BETHESDA MD 208143002 250.00 2007-09-29 35 ABRAMS, MICHAEL\n", + "137 138 ABRAMOWITZ KEN 200 CENTRAL PARK S. APARTMENT 31A NEW YORK NY 100191448 300.00 2007-09-11 35 ABRAMOWITZ, KEN\n", + "138 139 ABOUBAKARE NASAR 1400 SAN MIGUEL DRIVE CORONA DEL MAR CA 926251300 1000.00 2007-07-09 35 ABOUBAKARE, NASAR\n", + "139 140 ABEGG PATRICIA T. 1862 E. 5150 S. SALT LAKE CITY UT 841176911 75.00 2007-09-25 35 ABEGG, PATRICIA\n", + "140 141 ABEGG PATRICIA T. 1862 E. 5150 S. SALT LAKE CITY UT 841176911 25.00 2007-09-17 35 ABEGG, PATRICIA\n", + "141 142 ABEGG PATRICIA T. 1862 E. 5150 S. SALT LAKE CITY UT 841176911 75.00 2007-08-31 35 ABEGG, PATRICIA\n", + "142 143 ABEGG PATRICIA T. 1862 E. 5150 S. SALT LAKE CITY UT 841176911 75.00 2007-08-14 35 ABEGG, PATRICIA\n", + "143 144 ABEGG PATRICIA T. 1862 E. 5150 S. SALT LAKE CITY UT 841176911 25.00 2007-08-06 35 ABEGG, PATRICIA\n", + "144 145 ABEGG PATRICIA T. 1862 E. 5150 S. SALT LAKE CITY UT 841176911 25.00 2007-07-10 35 ABEGG, PATRICIA\n", + "145 146 ABDELLA THOMAS M. 4231 MONUMENT WALL WAY #340 FAIRFAX VA 220308440 50.00 2007-09-30 35 ABDELLA, THOMAS\n", + "146 147 ABBOTT WELDON S. 777 EAST SOUTH TEMPLE 4E SALT LAKE CITY UT 841021269 100.00 2007-09-29 35 ABBOTT, WELDON\n", + "147 148 ABBOTT WELDON S. 777 EAST SOUTH TEMPLE 4E SALT LAKE CITY UT 841021269 50.00 2007-08-09 35 ABBOTT, WELDON\n", + "148 149 ABBOTT GERALD F. 389 BENEFIT STREET PROVIDENCE RI 029032946 100.00 2007-09-15 35 ABBOTT, GERALD\n", + "149 150 ABBOTT GERALD F. 389 BENEFIT STREET PROVIDENCE RI 029032946 100.00 2007-08-15 35 ABBOTT, GERALD\n", + "150 151 ABEDIN ZAINUL 715 N. CENTRAL AVENUE SUITE 212 GLENDALE CA 912031164 500.00 2008-01-21 37 ABEDIN, ZAINUL\n", + "151 152 ABBOTT SYBIL F. 446 GAMES DRIVE RENO NV 895093326 75.00 2008-01-08 37 ABBOTT, SYBIL\n", + "152 153 ABBOTT SYBIL F. 446 GAMES DRIVE RENO NV 895093326 50.00 2008-01-08 37 ABBOTT, SYBIL\n", + "153 154 ABBOTT RONALD LEANDER 5453 HAWTHORNE STREET MONTCLAIR CA 917632551 200.00 2008-01-31 37 ABBOTT, RONALD\n", + "154 155 ABBOTT RONALD LEANDER 5453 HAWTHORNE STREET MONTCLAIR CA 917632551 100.00 2008-01-08 37 ABBOTT, RONALD\n", + "155 156 ABBOTT ROBERT A. 3061 LOREE ROAD DECKERVILLE MI 484279763 500.00 2008-01-21 37 ABBOTT, ROBERT\n", + "156 157 ABBOTT MIKE E. 4516 OSPREY LNDG NICEVILLE FL 325786810 1000.00 2008-01-15 37 ABBOTT, MIKE\n", + "157 158 ABBOT DAVID M. 56 SALEM STREET ANDOVER MA 018102114 200.00 2008-01-21 37 ABBOT, DAVID\n", + "158 159 ABBO PAULINE MORENCY 10720 JACOB LANE WHITE LAKE MI 483862274 35.00 2008-01-07 37 ABBO, PAULINE\n", + "159 160 ABATE MARIA ELENA 1291 NIGHTINGALE AVENUE MIAMI SPRINGS FL 331663832 2600.00 2008-01-25 37 Too Much\n", + "160 161 ABAIR PETER 40 EVANS STREET WATERTOWN MA 024722150 25.00 2008-01-09 37 ABAIR, PETER\n", + "161 162 ABACHERLI SHIRLEY M. 29875 NEWPORT ROAD MENIFEE CA 925849524 150.00 2008-01-28 37 ABACHERLI, SHIRLEY\n", + "162 163 AARONS CHARLES 1730 SHORE DRIVE ANCHORAGE AK 995153207 300.00 2008-01-30 37 AARONS, CHARLES\n", + "163 164 AARONS CHARLES 1730 SHORE DRIVE ANCHORAGE AK 995153207 410.00 2008-01-15 37 AARONS, CHARLES\n", + "164 165 AARONS CHARLES 1730 SHORE DRIVE ANCHORAGE AK 995153207 500.00 2008-01-09 37 AARONS, CHARLES\n", + "165 166 ABEL JOHN H. 422 THOMAS STREET BETHLEHEM PA 180153316 200.00 2008-01-22 37 ABEL, JOHN\n", + "166 167 ABEL MARLING L. 14 HANGING MOSS LANE GREENVILLE SC 296155069 100.00 2008-01-22 37 ABEL, MARLING\n", + "167 168 ABEL RUDOLPH 4532 OCEAN BLVD. # 108 SARASOTA FL 342421337 100.00 2008-01-08 37 ABEL, RUDOLPH\n", + "168 169 ABELE RODNEY 3620 METAIRIE HEIGHTS AVENUE METAIRIE LA 700021823 500.00 2008-01-15 37 ABELE, RODNEY\n", + "169 170 ABERCROMBIE DENIS 11811 WATER OAK CT MAGNOLIA TX 773546270 500.00 2008-01-30 37 ABERCROMBIE, DENIS\n", + "170 171 ABESHAUS MERRILL M. 1801 N. HEREFORD DRIVE FLAGSTAFF AZ 860011121 120.00 2008-01-16 37 ABESHAUS, MERRILL\n", + "171 172 ABRAHAM GEORGE P.O. BOX 1504 LAKE CHARLES LA 706021504 800.00 2008-01-17 37 ABRAHAM, GEORGE\n", + "172 173 ABRAHAMSON PETER J. 1030 W. ROSCOE STREET CHICAGO IL 606572207 50.00 2008-01-25 37 ABRAHAMSON, PETER\n", + "173 174 ABRAHAM SALEM A. P.O. BOX 7 CANADIAN TX 790140007 1000.00 2008-01-17 37 ABRAHAM, SALEM\n", + "174 175 ABRAHAM SALEM A. P.O. BOX 7 CANADIAN TX 790140007 1300.00 2008-01-30 37 Too Much" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "update = '''UPDATE contributors SET full_name = \"Too Much\" WHERE amount > 1000.00'''\n", + "cursor.execute(update)\n", + "viz_tables(contributor_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "d0d19339", + "metadata": {}, + "source": [ + "\n", + "# Step 6: Aggregation\n", + "\n", + "You can perform reduction operations on the values in the database. For\n", + "example, you can compute the maximum, minimum, sum or the total number from\n", + "multiple input values. Here's a little example:" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "21db7e96", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_idfull_name
031BuckelLindaPO Box 683130Park CityUT8406831304600.02007-08-1420Too Much
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id full_name\n", + "0 31 Buckel Linda PO Box 683130 Park City UT 840683130 4600.0 2007-08-14 20 Too Much" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "contributor_cols = [col[1] for col in cursor.execute(\"PRAGMA table_info(contributors)\")] # You've already done this part in your solution.\n", + "function = '''SELECT *, MAX(amount) AS max_amount FROM contributors'''\n", + "viz_tables(contributor_cols, function)" + ] + }, + { + "cell_type": "markdown", + "id": "bd673a63", + "metadata": {}, + "source": [ + "### Do the following:\n", + "\n", + "* Modify the demo to only output the max amount.\n", + " * **Hints:**\n", + " - Instead of using `SELECT *, MAX(amount) ...` you can try `SELECT\n", + " MAX(amount) ...`\n", + " - You will want to use `cursor.execute()` here and then `fetchall()`.\n", + " - Do not display your results in a table. It is sufficient to write\n", + " the answer out to the screen as a single number.\n", + "* Count how many donations there were above $\\$1000.00$.\n", + " * **Hint:** There is a `COUNT` function.\n", + "* Calculate the average *positive* donation.\n", + " * **Hint:** There is an `AVG` function.\n", + "* Calculate the average contribution from each state and display in a table.\n", + " Restrict to positive values again.\n", + " - **Hint**: Use code that looks like: `\"SELECT state,SUM(amount) FROM\n", + " contributors GROUP BY state\"`.\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "id": "c916e2b5-a15f-4f27-8368-cdf56ff0f149", + "metadata": {}, + "source": [ + "#### Modify the demo to only output the max amount.\n", + "Hints:\n", + "Instead of using SELECT *, MAX(amount) ... you can try SELECT MAX(amount) ...\n", + "You will want to use cursor.execute() here and then fetchall().\n", + "Do not display your results in a table. It is sufficient to write the answer out to the screen as a single number." + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "ec52a8ed-e490-4a9b-9bb2-3867edbfd4dc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(4600.0, 4600.0)\n" + ] + } + ], + "source": [ + "cursor.execute('''SELECT MAX(amount), MAX(amount) AS max_amount FROM contributors''')\n", + "amount = cursor.fetchall()\n", + "for i in amount:\n", + " print(amount[0])" + ] + }, + { + "cell_type": "markdown", + "id": "a1b7a5a6-d4d2-43ac-bd8a-acb1896a0898", + "metadata": {}, + "source": [ + "#### Count how many donations there were above $1000.00 .\n", + "Hint: There is a COUNT function." + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "d6c96b84-6078-40f3-a5e2-a47a23cbddf3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[(12,)]" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function = '''SELECT COUNT(*) FROM contributors WHERE amount > 1000.00'''\n", + "cursor.execute(function)\n", + "cursor.fetchall()" + ] + }, + { + "cell_type": "markdown", + "id": "6519c4ab-20c2-48b6-a319-549e9fb30474", + "metadata": {}, + "source": [ + "#### Calculate the average positive donation.\n", + "Hint: There is an AVG function." + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "c6346def-15ab-41d3-b693-794c423fc0ff", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[(480.6913675213675,)]" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function = '''SELECT AVG(amount) FROM contributors WHERE amount > 0'''\n", + "cursor.execute(function)\n", + "cursor.fetchall()" + ] + }, + { + "cell_type": "markdown", + "id": "34ab4265-6ef4-4286-8c9d-3f2ed0f12b28", + "metadata": {}, + "source": [ + "#### Calculate the average contribution from each state and display in a table. Restrict to positive values again.\n", + "Hint: Use code that looks like: \"SELECT state,SUM(amount) FROM contributors GROUP BY state\"." + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "6681c740-eff0-48cd-a9d9-86e519718b0e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[('AK', 403.3333333333333),\n", + " ('AR', 1183.3333333333333),\n", + " ('AZ', 120.0),\n", + " ('CA', 284.05333333333334),\n", + " ('CT', 2300.0),\n", + " ('DC', 225.04500000000002),\n", + " ('FL', 483.3333333333333),\n", + " ('IA', 250.0),\n", + " ('IL', 125.0),\n", + " ('LA', 650.0),\n", + " ('MA', 84.0),\n", + " ('MD', 150.0),\n", + " ('ME', 630.0),\n", + " ('MI', 258.75),\n", + " ('MN', 175.0),\n", + " ('MO', 100.0),\n", + " ('NC', 500.0),\n", + " ('NV', 181.25),\n", + " ('NY', 300.0),\n", + " ('OH', 216.66666666666666),\n", + " ('OK', 266.6666666666667),\n", + " ('PA', 200.0),\n", + " ('RI', 100.0),\n", + " ('SC', 800.0),\n", + " ('TX', 508.3333333333333),\n", + " ('UT', 735.0),\n", + " ('VA', 216.66666666666666),\n", + " ('WA', 100.0)]" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function = '''SELECT state, AVG(amount) FROM contributors WHERE amount > 0 GROUP BY state'''\n", + "cursor.execute(function)\n", + "cursor.fetchall()" + ] + }, + { + "cell_type": "markdown", + "id": "44d03a97-8bd5-4132-a07d-8f5daba8d312", + "metadata": {}, + "source": [ + "\n", + "# Step 7: DELETE\n", + "\n", + "We have already noted that `SQLite` can't drop columns in a straightforward\n", + "manner. However, it can delete rows quite simply. Here's the syntax:" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "03ce4229", + "metadata": {}, + "outputs": [], + "source": [ + "deletion = '''DELETE FROM table_name WHERE condition'''" + ] + }, + { + "cell_type": "markdown", + "id": "ef4e86d5", + "metadata": {}, + "source": [ + "### Do the following:\n", + "\n", + "* Delete rows in the `contributors` table with last name \"Ahrens\".\n" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "baf2d246-2ad3-4f3e-9147-9ea68c556f0e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_idfull_name
01AgeeSteven549 Laurel Branch RoadFloydVA24091500.02007-06-3016Agee, Steven
15AkinCharles10187 Sugar Creek RoadBentonvilleAR72712100.02007-06-1616Akin, Charles
26AkinMike181 Baywood LaneMonticelloAR716551500.02007-05-1816Too Much
37AkinRebecca181 Baywood LaneMonticelloAR71655500.02007-05-1816Akin, Rebecca
48AldridgeBrittni808 Capitol Square Place, SWWashingtonDC20024250.02007-06-0616Aldridge, Brittni
59AllenJohn D.1052 Cannon Mill DriveNorth AugustaSC298601000.02007-06-1116Allen, John D.
610AllenJohn D.1052 Cannon Mill DriveNorth AugustaSC298601300.02007-06-2916Too Much
711AllisonJohn W.P.O. Box 1089ConwayAR720331000.02007-05-1816Allison, John W.
812AllisonRebecca3206 Summit CourtLittle RockAR722271000.02007-04-2516Allison, Rebecca
913AllisonRebecca3206 Summit CourtLittle RockAR72227200.02007-06-1216Allison, Rebecca
1014AltesR.D.8600 Moody RoadFort SmithAR729032300.02007-06-2116Too Much
1115AndresDale1160 Glen Oaks DriveWest Des MoinesIA50266250.02007-06-0616Andres, Dale
1216AnthonyJohn211 Long Island DriveHot SpringsAR719132300.02007-06-1216Too Much
1317ArbogastRobert12900 State Route 56 SEMount SterlingOH43143500.02007-04-0816Arbogast, Robert
1418ArbogastRobert12900 State Route 56 SEMount SterlingOH43143100.02007-06-2216Arbogast, Robert
1519ArdleWilliam412 Dakota AvenueSpringfieldOH4550450.02007-06-2816Ardle, William
1620AtiqOmar7200 S Hazel StreetPine BluffAR716031000.02007-05-1816Atiq, Omar
1721AtiqOmar7200 S Hazel StreetPine BluffAR716031000.02007-06-2716Atiq, Omar
1822BakerDavid2550 Adamsbrooke DriveConwayAR720342300.02007-04-1116Too Much
1923BancroftDavid2934 Broderick StreetSan FranciscoCA94123250.02007-04-2416Bancroft, David
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id full_name\n", + "0 1 Agee Steven 549 Laurel Branch Road Floyd VA 24091 500.0 2007-06-30 16 Agee, Steven\n", + "1 5 Akin Charles 10187 Sugar Creek Road Bentonville AR 72712 100.0 2007-06-16 16 Akin, Charles\n", + "2 6 Akin Mike 181 Baywood Lane Monticello AR 71655 1500.0 2007-05-18 16 Too Much\n", + "3 7 Akin Rebecca 181 Baywood Lane Monticello AR 71655 500.0 2007-05-18 16 Akin, Rebecca\n", + "4 8 Aldridge Brittni 808 Capitol Square Place, SW Washington DC 20024 250.0 2007-06-06 16 Aldridge, Brittni\n", + "5 9 Allen John D. 1052 Cannon Mill Drive North Augusta SC 29860 1000.0 2007-06-11 16 Allen, John D.\n", + "6 10 Allen John D. 1052 Cannon Mill Drive North Augusta SC 29860 1300.0 2007-06-29 16 Too Much\n", + "7 11 Allison John W. P.O. Box 1089 Conway AR 72033 1000.0 2007-05-18 16 Allison, John W.\n", + "8 12 Allison Rebecca 3206 Summit Court Little Rock AR 72227 1000.0 2007-04-25 16 Allison, Rebecca\n", + "9 13 Allison Rebecca 3206 Summit Court Little Rock AR 72227 200.0 2007-06-12 16 Allison, Rebecca\n", + "10 14 Altes R.D. 8600 Moody Road Fort Smith AR 72903 2300.0 2007-06-21 16 Too Much\n", + "11 15 Andres Dale 1160 Glen Oaks Drive West Des Moines IA 50266 250.0 2007-06-06 16 Andres, Dale\n", + "12 16 Anthony John 211 Long Island Drive Hot Springs AR 71913 2300.0 2007-06-12 16 Too Much\n", + "13 17 Arbogast Robert 12900 State Route 56 SE Mount Sterling OH 43143 500.0 2007-04-08 16 Arbogast, Robert\n", + "14 18 Arbogast Robert 12900 State Route 56 SE Mount Sterling OH 43143 100.0 2007-06-22 16 Arbogast, Robert\n", + "15 19 Ardle William 412 Dakota Avenue Springfield OH 45504 50.0 2007-06-28 16 Ardle, William\n", + "16 20 Atiq Omar 7200 S Hazel Street Pine Bluff AR 71603 1000.0 2007-05-18 16 Atiq, Omar\n", + "17 21 Atiq Omar 7200 S Hazel Street Pine Bluff AR 71603 1000.0 2007-06-27 16 Atiq, Omar\n", + "18 22 Baker David 2550 Adamsbrooke Drive Conway AR 72034 2300.0 2007-04-11 16 Too Much\n", + "19 23 Bancroft David 2934 Broderick Street San Francisco CA 94123 250.0 2007-04-24 16 Bancroft, David" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "deletion = '''DELETE FROM contributors WHERE LOWER(last_name) = \"ahrens\"'''\n", + "cursor.execute(deletion)\n", + "function = '''SELECT * FROM contributors LIMIT 20'''\n", + "viz_tables(contributor_cols, function)" + ] + }, + { + "cell_type": "markdown", + "id": "1f1e64fa-cf1b-45c4-9cc3-9915fed04398", + "metadata": {}, + "source": [ + "\n", + "# Step 8: LIMIT\n", + "\n", + "The `LIMIT` clause offers convenient functionality. It allows you to constrain\n", + "the number of rows returned by your query. It shows up in many guises." + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "936f7be7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_initpartyfull_name
016MikeHuckabeeRHuckabee, Mike
120BarackObamaDWINNER
222RudolphGiulianiRGiuliani, Rudolph
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_init party full_name\n", + "0 16 Mike Huckabee R Huckabee, Mike\n", + "1 20 Barack Obama D WINNER\n", + "2 22 Rudolph Giuliani R Giuliani, Rudolph" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM candidates LIMIT 3'''\n", + "viz_tables(candidate_cols, query)" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "b1f6a91e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_initpartyfull_name
029BillRichardsonDRichardson, Bill
130DuncanHunterRHunter, Duncan
231DennisKucinichDKucinich, Dennis
332RonPaulRPaul, Ron
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_init party full_name\n", + "0 29 Bill Richardson D Richardson, Bill\n", + "1 30 Duncan Hunter R Hunter, Duncan\n", + "2 31 Dennis Kucinich D Kucinich, Dennis\n", + "3 32 Ron Paul R Paul, Ron" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM candidates LIMIT 4 OFFSET 5'''\n", + "viz_tables(candidate_cols, query)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "df1a856f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_initpartyfull_name
022RudolphGiulianiRGiuliani, Rudolph
124MikeGravelDGravel, Mike
216MikeHuckabeeRHuckabee, Mike
330DuncanHunterRHunter, Duncan
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_init party full_name\n", + "0 22 Rudolph Giuliani R Giuliani, Rudolph\n", + "1 24 Mike Gravel D Gravel, Mike\n", + "2 16 Mike Huckabee R Huckabee, Mike\n", + "3 30 Duncan Hunter R Hunter, Duncan" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM candidates ORDER BY last_name LIMIT 4 OFFSET 5'''\n", + "viz_tables(candidate_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "3aa48c1e", + "metadata": {}, + "source": [ + "### Do the following:\n", + "\n", + "* Query and display the ten most generous donors.\n", + "* Query and display the ten least generous donors who donated a positive amount\n", + " of money (since the data we have has some negative numbers in it...)." + ] + }, + { + "cell_type": "markdown", + "id": "2cc7388f-571f-4963-8bad-1ce8474b1fa8", + "metadata": {}, + "source": [ + "#### Query and display the ten most generous donors." + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "902952eb-3775-4ae1-9287-99c742623da7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_idfull_name
031BuckelLindaPO Box 683130Park CityUT8406831304600.02007-08-1420Too Much
1160ABATEMARIAELENA1291 NIGHTINGALE AVENUEMIAMI SPRINGSFL3316638322600.02008-01-2537Too Much
214AltesR.D.8600 Moody RoadFort SmithAR729032300.02007-06-2116Too Much
316AnthonyJohn211 Long Island DriveHot SpringsAR719132300.02007-06-1216Too Much
422BakerDavid2550 Adamsbrooke DriveConwayAR720342300.02007-04-1116Too Much
529BuckelLindaPO Box 683130Park CityUT8406831302300.02007-08-1420Too Much
634BuckBlaineM45 Eaton AveCamdenME0484317522300.02007-09-3020Too Much
7136ABRAMOWITZNIRA411 HARBOR ROADSOUTHPORTCT0689013762300.02007-09-1435Too Much
86AkinMike181 Baywood LaneMonticelloAR716551500.02007-05-1816Too Much
910AllenJohn D.1052 Cannon Mill DriveNorth AugustaSC298601300.02007-06-2916Too Much
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id full_name\n", + "0 31 Buckel Linda PO Box 683130 Park City UT 840683130 4600.0 2007-08-14 20 Too Much\n", + "1 160 ABATE MARIA ELENA 1291 NIGHTINGALE AVENUE MIAMI SPRINGS FL 331663832 2600.0 2008-01-25 37 Too Much\n", + "2 14 Altes R.D. 8600 Moody Road Fort Smith AR 72903 2300.0 2007-06-21 16 Too Much\n", + "3 16 Anthony John 211 Long Island Drive Hot Springs AR 71913 2300.0 2007-06-12 16 Too Much\n", + "4 22 Baker David 2550 Adamsbrooke Drive Conway AR 72034 2300.0 2007-04-11 16 Too Much\n", + "5 29 Buckel Linda PO Box 683130 Park City UT 840683130 2300.0 2007-08-14 20 Too Much\n", + "6 34 Buck Blaine M 45 Eaton Ave Camden ME 048431752 2300.0 2007-09-30 20 Too Much\n", + "7 136 ABRAMOWITZ NIRA 411 HARBOR ROAD SOUTHPORT CT 068901376 2300.0 2007-09-14 35 Too Much\n", + "8 6 Akin Mike 181 Baywood Lane Monticello AR 71655 1500.0 2007-05-18 16 Too Much\n", + "9 10 Allen John D. 1052 Cannon Mill Drive North Augusta SC 29860 1300.0 2007-06-29 16 Too Much" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM contributors ORDER BY amount DESC LIMIT 10'''\n", + "viz_tables(contributor_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "87ea3a15-8023-4ef9-967a-ad0e18ff7791", + "metadata": {}, + "source": [ + "#### Query and display the ten least generous donors who donated a positive amount of money (since the data we have has some negative numbers in it...)." + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "id": "b8dfc438-4061-41ae-a529-c01b0985cbf7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_idfull_name
027BucklerSteve24351 Armada DrDana PointCA92629130625.02007-08-1620Buckler, Steve
150HarrisonRyan2247 3rd StLa VerneCA91750491825.02007-07-2620Harrison, Ryan
2102AaronsElaine481 Buck Island Rd Apt 17AAPT 17AWest YarmouthMA02673330025.02008-02-2634Aarons, Elaine
3141ABEGGPATRICIAT.1862 E. 5150 S.SALT LAKE CITYUT84117691125.02007-09-1735ABEGG, PATRICIA
4144ABEGGPATRICIAT.1862 E. 5150 S.SALT LAKE CITYUT84117691125.02007-08-0635ABEGG, PATRICIA
5145ABEGGPATRICIAT.1862 E. 5150 S.SALT LAKE CITYUT84117691125.02007-07-1035ABEGG, PATRICIA
6161ABAIRPETER40 EVANS STREETWATERTOWNMA02472215025.02008-01-0937ABAIR, PETER
7159ABBOPAULINEMORENCY10720 JACOB LANEWHITE LAKEMI48386227435.02008-01-0737ABBO, PAULINE
819ArdleWilliam412 Dakota AvenueSpringfieldOH4550450.02007-06-2816Ardle, William
926BucklerSteve24351 Armada DrDana PointCA92629130650.02007-07-3020Buckler, Steve
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id full_name\n", + "0 27 Buckler Steve 24351 Armada Dr Dana Point CA 926291306 25.0 2007-08-16 20 Buckler, Steve\n", + "1 50 Harrison Ryan 2247 3rd St La Verne CA 917504918 25.0 2007-07-26 20 Harrison, Ryan\n", + "2 102 Aarons Elaine 481 Buck Island Rd Apt 17A APT 17A West Yarmouth MA 026733300 25.0 2008-02-26 34 Aarons, Elaine\n", + "3 141 ABEGG PATRICIA T. 1862 E. 5150 S. SALT LAKE CITY UT 841176911 25.0 2007-09-17 35 ABEGG, PATRICIA\n", + "4 144 ABEGG PATRICIA T. 1862 E. 5150 S. SALT LAKE CITY UT 841176911 25.0 2007-08-06 35 ABEGG, PATRICIA\n", + "5 145 ABEGG PATRICIA T. 1862 E. 5150 S. SALT LAKE CITY UT 841176911 25.0 2007-07-10 35 ABEGG, PATRICIA\n", + "6 161 ABAIR PETER 40 EVANS STREET WATERTOWN MA 024722150 25.0 2008-01-09 37 ABAIR, PETER\n", + "7 159 ABBO PAULINE MORENCY 10720 JACOB LANE WHITE LAKE MI 483862274 35.0 2008-01-07 37 ABBO, PAULINE\n", + "8 19 Ardle William 412 Dakota Avenue Springfield OH 45504 50.0 2007-06-28 16 Ardle, William\n", + "9 26 Buckler Steve 24351 Armada Dr Dana Point CA 926291306 50.0 2007-07-30 20 Buckler, Steve" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM contributors WHERE amount > 0 ORDER BY amount ASC LIMIT 10'''\n", + "viz_tables(contributor_cols, query)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "id": "2941f022", + "metadata": {}, + "source": [ + "\n", + "\n", + "Don't forget to save all of these changes to your database using `db.commit()`.\n", + "Before closing your editor or IDE, be sure to close the database connection with\n", + "`db.close()`." + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "005cc704-89ad-4463-ad28-8f8e57e096d8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "db.commit()\n", + "db.close" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7a20db91-6789-4cb6-9893-0e84cc1c29a9", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "jupytext": { + "formats": "md,ipynb" + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/lectures/lecture12/L22DB.sqlite b/lectures/lecture12/L22DB.sqlite new file mode 100644 index 0000000..24fe543 Binary files /dev/null and b/lectures/lecture12/L22DB.sqlite differ diff --git a/lectures/lecture12/L22DB_pandas.sqlite b/lectures/lecture12/L22DB_pandas.sqlite new file mode 100644 index 0000000..2e9ca6a Binary files /dev/null and b/lectures/lecture12/L22DB_pandas.sqlite differ diff --git a/lectures/lecture12/L22_EXercises.ipynb b/lectures/lecture12/L22_EXercises.ipynb new file mode 100644 index 0000000..54aec59 --- /dev/null +++ b/lectures/lecture12/L22_EXercises.ipynb @@ -0,0 +1,8744 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "8d63b077", + "metadata": {}, + "source": [ + "# Lecture 22\n", + "## Thursday, November 18th 2021\n", + "### Joins with `SQLite` and `pandas`" + ] + }, + { + "cell_type": "markdown", + "id": "bbe7abc2", + "metadata": {}, + "source": [ + "## Starting Up\n", + "\n", + "You can connect to the saved database from last time if you want.\n", + "Alternatively, for extra practice, you can just recreate it from the datasets\n", + "provided in the `.txt` files. That's what I'll do.\n", + "\n", + "# Exercise Deliverables\n", + "\n", + "> 1. Make a copy of this notebook and call it `L22_Exercises.ipynb`.\n", + "> 2. Do all exercises in _code cell(s) immediately after the \"Exercise\"\n", + "> statement_ similarly to what you did in Lecture 21.\n", + "> 3. Be sure to upload your database with the\n", + "> lecture exercises. You must name your database **`L22DB.sqlite`** and\n", + "> **`L22DB_pandas.sqlite`**.\n", + "> 4. Commit your completed work to your class `git` repo inside the directory\n", + "> `lectures/lecture22` on the `main` (or `master`) branch, similarly to what\n", + "> you did in Lecture 21.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "ee27a7d0", + "metadata": {}, + "outputs": [], + "source": [ + "import sqlite3\n", + "import numpy as np\n", + "import pandas as pd\n", + "import time\n", + "pd.set_option('display.width', 500)\n", + "pd.set_option('display.max_rows', None)\n", + "pd.set_option('display.max_columns', 100)\n", + "pd.set_option('display.notebook_repr_html', True)\n", + "\n", + "db = sqlite3.connect('L22DB.sqlite')\n", + "cursor = db.cursor()\n", + "cursor.execute(\"DROP TABLE IF EXISTS candidates\")\n", + "cursor.execute(\"DROP TABLE IF EXISTS contributors\")\n", + "cursor.execute(\"PRAGMA foreign_keys=1\")\n", + "\n", + "cursor.execute('''CREATE TABLE candidates (\n", + " id INTEGER PRIMARY KEY NOT NULL, \n", + " first_name TEXT, \n", + " last_name TEXT, \n", + " middle_init TEXT, \n", + " party TEXT NOT NULL)''')\n", + "\n", + "db.commit() # Commit changes to the database\n", + "\n", + "cursor.execute('''CREATE TABLE contributors (\n", + " id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \n", + " last_name TEXT, \n", + " first_name TEXT, \n", + " middle_name TEXT, \n", + " street_1 TEXT, \n", + " street_2 TEXT, \n", + " city TEXT, \n", + " state TEXT, \n", + " zip TEXT, \n", + " amount REAL, \n", + " date DATETIME, \n", + " candidate_id INTEGER NOT NULL, \n", + " FOREIGN KEY(candidate_id) REFERENCES candidates(id))''')\n", + "\n", + "db.commit()\n", + "\n", + "with open (\"candidates.txt\") as candidates:\n", + " next(candidates) # jump over the header\n", + " for line in candidates.readlines():\n", + " vals_to_insert = line.strip().split('|')\n", + " cursor.execute('''INSERT INTO candidates \n", + " (id, first_name, last_name, middle_init, party)\n", + " VALUES (?, ?, ?, ?, ?)''', vals_to_insert)\n", + "\n", + "with open (\"contributors.txt\") as contributors:\n", + " next(contributors) # jump over the header\n", + " for line in contributors.readlines():\n", + " vals_to_insert = line.strip().split('|')[1:]\n", + " cursor.execute('''INSERT INTO contributors (last_name, first_name, middle_name, \n", + " street_1, street_2, city, state, zip, amount, date, candidate_id) \n", + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', vals_to_insert)\n", + "\n", + "candidate_cols = [col[1] for col in cursor.execute(\"PRAGMA table_info(candidates)\")]\n", + "contributor_cols = [col[1] for col in cursor.execute(\"PRAGMA table_info(contributors)\")]\n", + "\n", + "def viz_tables(cols, query):\n", + " q = cursor.execute(query).fetchall()\n", + " framelist = dict()\n", + " for i, col_name in enumerate(cols):\n", + " framelist[col_name] = [col[i] for col in q]\n", + " return pd.DataFrame.from_dict(framelist)\n", + "\n", + "from IPython.display import display" + ] + }, + { + "cell_type": "markdown", + "id": "4ab0105a", + "metadata": {}, + "source": [ + "## Recap\n", + "\n", + "Last time, you played with a number of `SQLite` commands to query and update the\n", + "tables in the database.\n", + "\n", + "One thing we didn't get to was how to query the contributors table based off of\n", + "a query in the candidates table. For example, suppose you want to query which\n", + "contributors donated to Obama. You could use a nested `SELECT` statement to\n", + "accomplish that." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "b2e61c76", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
026BucklerSteve24351 Armada DrDana PointCA92629130650.002007-07-3020
127BucklerSteve24351 Armada DrDana PointCA92629130625.002007-08-1620
228BuckheitBruce8904 KAREN DRFAIRFAXVA220312731100.002007-09-1920
329BuckelLindaPO Box 683130Park CityUT8406831302300.002007-08-1420
430BuckelLindaPO Box 683130Park CityUT840683130-2300.002007-08-1420
531BuckelLindaPO Box 683130Park CityUT8406831304600.002007-08-1420
632BuckThomas4206 Terrace StreetKansas CityMO64111100.002007-09-2520
733BuckJayK.1855 Old Willow Rd Unit 322NorthfieldIL600932918200.002007-09-1220
834BuckBlaineM45 Eaton AveCamdenME0484317522300.002007-09-3020
935BuckBarbara1780 NE 138th StNorth MiamiFL33181131650.002007-09-1320
1036BuckBarbara1780 NE 138th StNorth MiamiFL33181131650.002007-07-1920
1137BuchmanMark M2530 Lawton AveSan Luis ObispoCA934015622460.802007-07-1820
1238BucherIdaM1400 Warnall AveLos AngelesCA900245333100.002007-07-1020
1339BuchanekElizabeth7917 Kentbury DrBethesdaMD20814461550.002007-09-3020
1440BuchananJohn2025 NW 29th RdBoca RatonFL334316303500.002007-09-2420
1541BuchananJohn2025 NW 29th RdBoca RatonFL334316303-500.002007-09-2420
1642BuchananJohn2025 NW 29th RdBoca RatonFL334316303500.002007-09-2420
1743BuchananJohn2025 NW 29th RdBoca RatonFL334316303700.002007-08-2820
1844BuchananJohn2025 NW 29th RdBoca RatonFL334316303-700.002007-08-2820
1945BuchananJohn2025 NW 29th RdBoca RatonFL3343163031000.002007-08-2820
2046BuchananJohn2025 NW 29th RdBoca RatonFL3343163031300.002007-08-0920
2147BuchananJohn2025 NW 29th RdBoca RatonFL334316303200.002007-08-1420
2248BuchananJohn2025 NW 29th RdBoca RatonFL334316303500.002007-07-2520
2349BuchananJohn4635 49th St NWWashingtonDC200164320200.092007-09-2320
2450HarrisonRyan2247 3rd StLa VerneCA91750491825.002007-07-2620
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 26 Buckler Steve 24351 Armada Dr Dana Point CA 926291306 50.00 2007-07-30 20\n", + "1 27 Buckler Steve 24351 Armada Dr Dana Point CA 926291306 25.00 2007-08-16 20\n", + "2 28 Buckheit Bruce 8904 KAREN DR FAIRFAX VA 220312731 100.00 2007-09-19 20\n", + "3 29 Buckel Linda PO Box 683130 Park City UT 840683130 2300.00 2007-08-14 20\n", + "4 30 Buckel Linda PO Box 683130 Park City UT 840683130 -2300.00 2007-08-14 20\n", + "5 31 Buckel Linda PO Box 683130 Park City UT 840683130 4600.00 2007-08-14 20\n", + "6 32 Buck Thomas 4206 Terrace Street Kansas City MO 64111 100.00 2007-09-25 20\n", + "7 33 Buck Jay K. 1855 Old Willow Rd Unit 322 Northfield IL 600932918 200.00 2007-09-12 20\n", + "8 34 Buck Blaine M 45 Eaton Ave Camden ME 048431752 2300.00 2007-09-30 20\n", + "9 35 Buck Barbara 1780 NE 138th St North Miami FL 331811316 50.00 2007-09-13 20\n", + "10 36 Buck Barbara 1780 NE 138th St North Miami FL 331811316 50.00 2007-07-19 20\n", + "11 37 Buchman Mark M 2530 Lawton Ave San Luis Obispo CA 934015622 460.80 2007-07-18 20\n", + "12 38 Bucher Ida M 1400 Warnall Ave Los Angeles CA 900245333 100.00 2007-07-10 20\n", + "13 39 Buchanek Elizabeth 7917 Kentbury Dr Bethesda MD 208144615 50.00 2007-09-30 20\n", + "14 40 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 500.00 2007-09-24 20\n", + "15 41 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 -500.00 2007-09-24 20\n", + "16 42 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 500.00 2007-09-24 20\n", + "17 43 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 700.00 2007-08-28 20\n", + "18 44 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 -700.00 2007-08-28 20\n", + "19 45 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 1000.00 2007-08-28 20\n", + "20 46 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 1300.00 2007-08-09 20\n", + "21 47 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 200.00 2007-08-14 20\n", + "22 48 Buchanan John 2025 NW 29th Rd Boca Raton FL 334316303 500.00 2007-07-25 20\n", + "23 49 Buchanan John 4635 49th St NW Washington DC 200164320 200.09 2007-09-23 20\n", + "24 50 Harrison Ryan 2247 3rd St La Verne CA 917504918 25.00 2007-07-26 20" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT * FROM contributors WHERE candidate_id = (SELECT id from candidates WHERE last_name = \"Obama\")'''\n", + "viz_tables(contributor_cols, query)" + ] + }, + { + "cell_type": "markdown", + "id": "2801fdb8", + "metadata": {}, + "source": [ + "# Joins\n", + "\n", + "The last example involved querying data from multiple tables.\n", + "\n", + "In particular, we combined columns from the two related tables (related through\n", + "the `FOREIGN KEY`).\n", + "\n", + "This leads to the idea of *joining* multiple tables together. `SQL` has a set\n", + "of commands to handle different types of joins. `SQLite` does not support the\n", + "full suite of join commands offered by `SQL` but you should still be able to get\n", + "the main ideas from the limited command set.\n", + "\n", + "We'll begin with the `INNER JOIN`." + ] + }, + { + "cell_type": "markdown", + "id": "c9695740", + "metadata": {}, + "source": [ + "## INNER JOIN\n", + "\n", + "The idea here is that you will combine the tables if the values of certain\n", + "columns are the same between the two tables. In our example, we will join the\n", + "two tables based on the candidate `id`. The result of the `INNER JOIN` will be\n", + "a new table consisting of the columns we requested and containing the common\n", + "data. Since we are joining based off of the candidate `id`, we will not be\n", + "excluding any rows.\n", + "\n", + "### Example\n", + "\n", + "Here are two tables. Table A has the form:\n", + "\n", + "| nA | attr | idA |\n", + "| :::: | ::::: | ::: |\n", + "| s1 | 23 | 0 |\n", + "| s2 | 7 | 2 |\n", + "\n", + "and table B has the form:\n", + "\n", + "| nB | attr | idB |\n", + "| :::: | ::::: | ::: |\n", + "| t1 | 60 | 0 |\n", + "| t2 | 14 | 7 |\n", + "| t3 | 22 | 2 |\n", + "\n", + "Table A is associated with Table B through a foreign key on the id column.\n", + "\n", + "If we join the two tables by comparing the id columns and selecting the nA, nB,\n", + "and attr columns then we'll get \n", + "\n", + "| nA | A.attr | nB | B.attr |\n", + "| :::: | ::::::: | ::: | :::::: |\n", + "| s1 | 23 | t1 | 60 |\n", + "| s2 | 7 | t3 | 22 |\n", + "\n", + "\n", + "The `SQLite` code to do this join would be \n", + "\n", + "```SQL\n", + "SELECT nA, A.attr, nB, B.attr FROM A INNER JOIN B ON B.idB = A.idA\n", + "```\n", + "\n", + "Notice that the second row in table B is gone because the id values are not the\n", + "same.\n", + "\n", + "### Visualization\n", + "\n", + "What is `SQL` doing with this operation? It may help to visualize this with a\n", + "Venn diagram. Table A has rows with values corresponding to the `idA`\n", + "attribute. Column B has rows with values corresponding to the `idB` attribute.\n", + "The `INNER JOIN` will combine the two tables such that rows with common entries\n", + "in the `id` attributes are included. We essentially have the following Venn\n", + "diagram.\n", + "\n", + "![]({static}../fig/inner_join.png)" + ] + }, + { + "cell_type": "markdown", + "id": "1c12c276", + "metadata": {}, + "source": [ + "## Exercises\n", + "\n", + "1. Using an `INNER JOIN`, join the `candidates` and `contributors` tables by\n", + " comparing the `id` column in the `candidates` table with the `candidate_id`\n", + " column in the `contributors` table. Display your joined table with the\n", + " columns `contributors.last_name`, `contributors.first_name`, `amount` and\n", + " `candidates.last_name`.\n", + "2. Do the same inner join as in the last part, but this time append a `WHERE`\n", + " clause to select a specific candidate's last name.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "466e1805-cf44-43c7-ab08-90b18d104f22", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
contributors.last_namecontributors.first_nameamountcandidates.last_name
0AgeeSteven500.0Huckabee
1AhrensDon250.0Huckabee
2AhrensDon50.0Huckabee
3AhrensDon100.0Huckabee
4AkinCharles100.0Huckabee
\n", + "
" + ], + "text/plain": [ + " contributors.last_name contributors.first_name amount candidates.last_name\n", + "0 Agee Steven 500.0 Huckabee\n", + "1 Ahrens Don 250.0 Huckabee\n", + "2 Ahrens Don 50.0 Huckabee\n", + "3 Ahrens Don 100.0 Huckabee\n", + "4 Akin Charles 100.0 Huckabee" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "col = [\"contributors.last_name\",\"contributors.first_name\",\"amount\", \"candidates.last_name\"]\n", + "query = '''SELECT contributors.last_name,contributors.first_name,amount, candidates.last_name FROM candidates INNER JOIN contributors ON contributors.candidate_id = candidates.id'''\n", + "viz_tables(col, query).head()\n", + "#cursor.execute(query).fetchall()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "986faf15-9426-435e-aab5-217a3b18a121", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
contributors.last_namecontributors.first_namecontributors.amountcandidates.last_name
0BucklerSteve50.0Obama
1BucklerSteve25.0Obama
2BuckheitBruce100.0Obama
3BuckelLinda2300.0Obama
4BuckelLinda-2300.0Obama
\n", + "
" + ], + "text/plain": [ + " contributors.last_name contributors.first_name contributors.amount candidates.last_name\n", + "0 Buckler Steve 50.0 Obama\n", + "1 Buckler Steve 25.0 Obama\n", + "2 Buckheit Bruce 100.0 Obama\n", + "3 Buckel Linda 2300.0 Obama\n", + "4 Buckel Linda -2300.0 Obama" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT contributors.last_name, contributors.first_name, contributors.amount, candidates.last_name \n", + "FROM candidates INNER JOIN contributors ON contributors.candidate_id = candidates.id WHERE\n", + "lower(candidates.last_name) == \"obama\" '''\n", + "viz_tables([\"contributors.last_name\",\"contributors.first_name\",\"contributors.amount\", \"candidates.last_name\"], query).head()\n", + "#cursor.execute(query).fetchall()" + ] + }, + { + "cell_type": "markdown", + "id": "8e462543", + "metadata": {}, + "source": [ + "## `LEFT JOIN` or `LEFT OUTER JOIN`\n", + "\n", + "There are many ways to combine two tables. We just explored one possibility in\n", + "which we combined the tables based upon the intersection of the two tables (the\n", + "`INNER JOIN`).\n", + "\n", + "Now we'll look at the `LEFT JOIN` or `LEFT OUTER JOIN` in some databases.\n", + "\n", + "In words, the `LEFT JOIN` is combining the tables based upon what is in the\n", + "intersection of the two tables *and* what is in the \"reference\" table (left\n", + "table in the `SQL` command).\n", + "\n", + "We can consider our toy example in two guises:\n", + "\n", + "#### Example A\n", + "\n", + "Let's do a `LEFT JOIN` of table B from table A. That is, we'd like to make a\n", + "new table by putting table B into table A. In this case, we'll consider table A\n", + "our \"reference\" table. We're comparing by the `id` column again. We know that\n", + "these two tables share ids 0 and 2 and table A doesn't have anything else in it.\n", + "The resulting table is:\n", + "\n", + "| nA | A.attr | nB | B.attr |\n", + "| :::: | ::::::: | ::: | :::::: |\n", + "| s1 | 23 | t1 | 60 |\n", + "| s2 | 7 | t3 | 22 |\n", + "\n", + "That's not very exciting. It's the same result as from the `INNER JOIN`. We\n", + "can do another example that may be more enlightening.\n", + "\n", + "#### Example B\n", + "\n", + "Let's do a `LEFT JOIN` of table A from table B. That is, we'd like to make a\n", + "new table by putting table A into table B. In this case, we'll consider table B\n", + "our \"reference\" table. Again, we use the `id` column from comparison. We know\n", + "that these two tables share ids 0 and 2. This time, table B also contains the\n", + "id 7, which is not shared by table A. The resulting table is:\n", + "\n", + "| nA | A.attr | nB | B.attr |\n", + "| :::: | ::::::: | ::: | :::::: |\n", + "| s1 | 23 | t1 | 60 |\n", + "| None | NaN | t2 | 14 |\n", + "| s2 | 7 | t3 | 22 |\n", + "\n", + "Notice that `SQLite` filled in the missing entries for us. This is necessary\n", + "for completion of the requested join.\n", + "\n", + "The `SQLite` commands to accomplish all of this are:\n", + "\n", + "```SQL\n", + "SELECT nA, A.attr, nB, B.attr FROM A LEFT JOIN B ON B.idB = A.idA\n", + "```\n", + "\n", + "and\n", + "\n", + "```SQL\n", + "SELECT nA, A.attr, nB, B.attr FROM B LEFT JOIN A ON A.idA = B.idB\n", + "```\n", + "\n", + "Here is a visualization using Venn diagrams of the `LEFT JOIN`.\n", + "\n", + "![]({static}../fig/left_join.png)" + ] + }, + { + "cell_type": "markdown", + "id": "e2146d49", + "metadata": {}, + "source": [ + "## Exercises\n", + "\n", + "Use the following two tables to do the first two exercises in this section.\n", + "Table A has the form:\n", + "\n", + "| nA | attr | idA |\n", + "| :::: | ::::: | ::: |\n", + "| s1 | 23 | 0 |\n", + "| s2 | 7 | 2 |\n", + "| s3 | 15 | 3 |\n", + "| s4 | 31 | 7 |\n", + "\n", + "and table B has the form:\n", + "\n", + "| nB | attr | idB |\n", + "| :::: | ::::: | ::: |\n", + "| t1 | 60 | 0 |\n", + "| t2 | 14 | 7 |\n", + "| t3 | 22 | 2 |\n", + "\n", + "1. Write the markdown table that would result from a `LEFT JOIN` using table A\n", + " as the reference and the `id` columns for comparison. Example with arbitrary\n", + " column names:\n", + " ```md\n", + " | Col1 | Col2 | Col3 | Col4 |\n", + " | :::: | :::: | :::: | :::: |\n", + " | val1 | val2 | val3 | val4 |\n", + " | val5 | val6 | val7 | val8 |\n", + " ```\n", + "2. Write the markdown table that would result from a `LEFT JOIN` using table B\n", + " as the reference and the `id` columns for comparison.\n", + "3. Now back to the candidates and their contributors. Create a new table with\n", + " the following form:\n", + " ```md\n", + " | average contribution | candidate last name |\n", + " | :::::::::::::::::::: | ::::::::::::::::::: |\n", + " | ... | ... |\n", + " ```\n", + " The table should be created using the `LEFT JOIN` clause on the\n", + " `contributors` table by joining the `candidates` table by the `id` column.\n", + " The `average contribution` column should be obtained using the `AVG()` `SQL`\n", + " function. Use the `GROUP BY` clause on the `candidates` last name.\n", + "\n", + "---" + ] + }, + { + "cell_type": "markdown", + "id": "f45acd51-dc47-4fa6-8b0f-489f277d65b1", + "metadata": {}, + "source": [ + "Left JOIN using table A as the reference\n", + "\n", + "|na|attr|idA|nB|attr|idb|\n", + "|::|::::|:::|::|::::|:::|\n", + "|s1|23. | 0 |t1|60. | 0 |\n", + "|s2|7. | 2 |t3|22. |2. |\n", + "|s3| 15 |3. |null|null|null|\n", + "|s4|31. |7. |t2|14|7|" + ] + }, + { + "cell_type": "markdown", + "id": "ace8c299-47ee-4b7e-a1ae-2379e318661b", + "metadata": {}, + "source": [ + "LEFT Join using Table B as the reference\n", + "\n", + "|nB|attr|idb|na|attr|idA|\n", + "|::|::::|:::|::|::::|:::|\n", + "|t1|60. | 0 |s1|23. | 0 |\n", + "|t2|14|7|s4|31. |7.| \n", + "|t3|22. |2. |s2|7. | 2 |\n" + ] + }, + { + "cell_type": "markdown", + "id": "910c9758-490b-4769-9ad5-e7a15ed889ff", + "metadata": {}, + "source": [ + " The table should be created using the `LEFT JOIN` clause on the\n", + " `contributors` table by joining the `candidates` table by the `id` column.\n", + " The `average contribution` column should be obtained using the `AVG()` `SQL`\n", + " function. Use the `GROUP BY` clause on the `candidates` last name." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "393ef27f-4b65-4556-a89e-f8aa258e5427", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Amount_avgcandidates.last_name
050.6000Clinton
1-1360.0000Giuliani
2772.0000Huckabee
3452.6000McCain
4472.4356Obama
5-519.7088Paul
6156.0000Romney
\n", + "
" + ], + "text/plain": [ + " Amount_avg candidates.last_name \n", + "0 50.6000 Clinton\n", + "1 -1360.0000 Giuliani\n", + "2 772.0000 Huckabee\n", + "3 452.6000 McCain\n", + "4 472.4356 Obama\n", + "5 -519.7088 Paul\n", + "6 156.0000 Romney" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = '''SELECT AVG(amount), candidates.last_name AS Amount_avg FROM contributors LEFT JOIN candidates \n", + "ON contributors.candidate_id = candidates.id GROUP BY candidates.last_name'''\n", + "viz_tables([\"Amount_avg\",\"candidates.last_name \"], query)" + ] + }, + { + "cell_type": "markdown", + "id": "7a608a69", + "metadata": {}, + "source": [ + "# `pandas`" + ] + }, + { + "cell_type": "markdown", + "id": "e9962018", + "metadata": {}, + "source": [ + "We've been working with databases for the last few lectures and learning\n", + "`SQLite` commands to work with and manipulate the `SQL` databases. There is a\n", + "powerful `python` package called `pandas` that provides broad support for data\n", + "structures. It can be used to interact with relational databases through its\n", + "own methods and even through `SQL` commands.\n", + "\n", + "> In the last part of this lecture, you will get to redo a number of the\n", + "> previous database exercises using `pandas`.\n", + "\n", + "We won't be able to cover `pandas` from the ground up, but it's a\n", + "well-documented library and is fairly easy to get up and running. The website\n", + "can be found at the following link: [`pandas`](http://pandas.pydata.org/). A\n", + "very good reference for `pandas` is the book [\"Python for data\n", + "analysis\"](https://www.amazon.com/gp/product/1491957662/ref=as_li_tl?ie=UTF8&tag=quantpytho-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=1491957662&linkId=8c3bf87b221dbcd8f541f0db20d4da83)\n", + "by the creator of `pandas` himself." + ] + }, + { + "cell_type": "markdown", + "id": "c3b3f76d", + "metadata": {}, + "source": [ + "## Reading a datafile into `pandas`" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "daf5676d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_nameparty
033JosephBidenNaND
136SamuelBrownbackNaNR
234HillaryClintonR.D
339ChristopherDoddJ.D
426JohnEdwardsNaND
522RudolphGiulianiNaNR
624MikeGravelNaND
716MikeHuckabeeNaNR
830DuncanHunterNaNR
931DennisKucinichNaND
1037JohnMcCainNaNR
1120BarackObamaNaND
1232RonPaulNaNR
1329BillRichardsonNaND
1435MittRomneyNaNR
1538TomTancredoNaNR
1641FredThompsonD.R
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party\n", + "0 33 Joseph Biden NaN D\n", + "1 36 Samuel Brownback NaN R\n", + "2 34 Hillary Clinton R. D\n", + "3 39 Christopher Dodd J. D\n", + "4 26 John Edwards NaN D\n", + "5 22 Rudolph Giuliani NaN R\n", + "6 24 Mike Gravel NaN D\n", + "7 16 Mike Huckabee NaN R\n", + "8 30 Duncan Hunter NaN R\n", + "9 31 Dennis Kucinich NaN D\n", + "10 37 John McCain NaN R\n", + "11 20 Barack Obama NaN D\n", + "12 32 Ron Paul NaN R\n", + "13 29 Bill Richardson NaN D\n", + "14 35 Mitt Romney NaN R\n", + "15 38 Tom Tancredo NaN R\n", + "16 41 Fred Thompson D. R" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Using pandas naming convention\n", + "dfcand = pd.read_csv(\"candidates.txt\", sep=\"|\")\n", + "dfcand" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "38244660", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idlast_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
0NaNAgeeStevenNaN549 Laurel Branch RoadNaNFloydVA24091500.02007-06-3016
1NaNAhrensDonNaN4034 Rennellwood WayNaNPleasantonCA94566250.02007-05-1616
2NaNAhrensDonNaN4034 Rennellwood WayNaNPleasantonCA9456650.02007-06-1816
3NaNAhrensDonNaN4034 Rennellwood WayNaNPleasantonCA94566100.02007-06-2116
4NaNAkinCharlesNaN10187 Sugar Creek RoadNaNBentonvilleAR72712100.02007-06-1616
\n", + "
" + ], + "text/plain": [ + " id last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 NaN Agee Steven NaN 549 Laurel Branch Road NaN Floyd VA 24091 500.0 2007-06-30 16\n", + "1 NaN Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 250.0 2007-05-16 16\n", + "2 NaN Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 50.0 2007-06-18 16\n", + "3 NaN Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 100.0 2007-06-21 16\n", + "4 NaN Akin Charles NaN 10187 Sugar Creek Road NaN Bentonville AR 72712 100.0 2007-06-16 16" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr = pd.read_csv(\"contributors.txt\", sep=\"|\")\n", + "dfcontr.head()" + ] + }, + { + "cell_type": "markdown", + "id": "1f989838", + "metadata": {}, + "source": [ + "Reading things in is quite easy with `pandas`. Notice that `pandas` populates\n", + "empty fields with `NaN` values. The `id` column in the `contributors` dataset is\n", + "superfluous. Let's delete it." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "c69cbd93", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
0AgeeStevenNaN549 Laurel Branch RoadNaNFloydVA24091500.02007-06-3016
1AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA94566250.02007-05-1616
2AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA9456650.02007-06-1816
3AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA94566100.02007-06-2116
4AkinCharlesNaN10187 Sugar Creek RoadNaNBentonvilleAR72712100.02007-06-1616
\n", + "
" + ], + "text/plain": [ + " last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 Agee Steven NaN 549 Laurel Branch Road NaN Floyd VA 24091 500.0 2007-06-30 16\n", + "1 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 250.0 2007-05-16 16\n", + "2 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 50.0 2007-06-18 16\n", + "3 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 100.0 2007-06-21 16\n", + "4 Akin Charles NaN 10187 Sugar Creek Road NaN Bentonville AR 72712 100.0 2007-06-16 16" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "del dfcontr['id']\n", + "dfcontr.head()" + ] + }, + { + "cell_type": "markdown", + "id": "1177054b", + "metadata": {}, + "source": [ + "Very nice! And we used the `head` method to print out the first five rows." + ] + }, + { + "cell_type": "markdown", + "id": "372c68d9", + "metadata": {}, + "source": [ + "## Creating a Table with `pandas`\n", + "\n", + "We can use `pandas` to create tables in a database. First, let's create a new\n", + "(empty) `SQLite` database:" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "4830fb87", + "metadata": {}, + "outputs": [], + "source": [ + "dbp = sqlite3.connect('L22DB_pandas.sqlite')\n", + "cursor = dbp.cursor()\n", + "cursor.execute(\"DROP TABLE IF EXISTS candidates\")\n", + "cursor.execute(\"DROP TABLE IF EXISTS contributors\")\n", + "cursor.execute(\"PRAGMA foreign_keys=1\")\n", + "\n", + "cursor.execute('''CREATE TABLE candidates (\n", + " id INTEGER PRIMARY KEY NOT NULL, \n", + " first_name TEXT, \n", + " last_name TEXT, \n", + " middle_name TEXT, \n", + " party TEXT NOT NULL)''')\n", + "\n", + "dbp.commit() # Commit changes to the database\n", + "\n", + "cursor.execute('''CREATE TABLE contributors (\n", + " id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \n", + " last_name TEXT, \n", + " first_name TEXT, \n", + " middle_name TEXT, \n", + " street_1 TEXT, \n", + " street_2 TEXT, \n", + " city TEXT, \n", + " state TEXT, \n", + " zip TEXT, \n", + " amount REAL, \n", + " date DATETIME, \n", + " candidate_id INTEGER NOT NULL, \n", + " FOREIGN KEY(candidate_id) REFERENCES candidates(id))''')\n", + "\n", + "dbp.commit()" + ] + }, + { + "cell_type": "markdown", + "id": "3d335768", + "metadata": {}, + "source": [ + "Last time, we opened the data files with `python` and then manually used\n", + "`SQLite` commands to populate the individual tables. We can use `pandas`\n", + "instead like so:" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "2ef39d41", + "metadata": {}, + "outputs": [], + "source": [ + "dfcand.to_sql(\"candidates\", dbp, if_exists=\"append\", index=False)" + ] + }, + { + "cell_type": "markdown", + "id": "74e41652", + "metadata": {}, + "source": [ + "What is the size of our table?" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "dda8ab8a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(17, 5)" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand.shape" + ] + }, + { + "cell_type": "markdown", + "id": "bccda7d1", + "metadata": {}, + "source": [ + "We can visualize the data in our `pandas`-populated `SQL` table. No surprises\n", + "here except that `pandas` did everything for us (contrast this to our manual\n", + "file read last time using `for`-loops and list comprehensions)." + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "7205d082", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Average Contributioncandidates.last_name
016Mike
120Barack
222Rudolph
324Mike
426John
529Bill
630Duncan
731Dennis
832Ron
933Joseph
1034Hillary
1135Mitt
1236Samuel
1337John
1438Tom
1539Christopher
1641Fred
\n", + "
" + ], + "text/plain": [ + " Average Contribution candidates.last_name\n", + "0 16 Mike\n", + "1 20 Barack\n", + "2 22 Rudolph\n", + "3 24 Mike\n", + "4 26 John\n", + "5 29 Bill\n", + "6 30 Duncan\n", + "7 31 Dennis\n", + "8 32 Ron\n", + "9 33 Joseph\n", + "10 34 Hillary\n", + "11 35 Mitt\n", + "12 36 Samuel\n", + "13 37 John\n", + "14 38 Tom\n", + "15 39 Christopher\n", + "16 41 Fred" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "query = '''SELECT * FROM candidates'''\n", + "display(viz_tables([\"Average Contribution\", \"candidates.last_name\"], query))" + ] + }, + { + "cell_type": "markdown", + "id": "6463c34e", + "metadata": {}, + "source": [ + "## Querying a table with `pandas`" + ] + }, + { + "cell_type": "markdown", + "id": "09479688", + "metadata": {}, + "source": [ + "### One Way\n", + "\n", + "Using the `query` method:" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "4dfdae96", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_nameparty
624MikeGravelNaND
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party\n", + "6 24 Mike Gravel NaN D" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand.query(\"first_name=='Mike' & party=='D'\")" + ] + }, + { + "cell_type": "markdown", + "id": "8d5ac2e6", + "metadata": {}, + "source": [ + "### Another Way\n", + "\n", + "Using the `__getitem__` special method:" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "a0ff20ba", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_nameparty
624MikeGravelNaND
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party\n", + "6 24 Mike Gravel NaN D" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand[(dfcand.first_name==\"Mike\") & (dfcand.party==\"D\")]" + ] + }, + { + "cell_type": "markdown", + "id": "d0443eef", + "metadata": {}, + "source": [ + "### More Queries" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "6e9d78ac", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_nameparty
234HillaryClintonR.D
339ChristopherDoddJ.D
1641FredThompsonD.R
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party\n", + "2 34 Hillary Clinton R. D\n", + "3 39 Christopher Dodd J. D\n", + "16 41 Fred Thompson D. R" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand[dfcand.middle_name.notnull()]" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "dd900a67", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_nameparty
234HillaryClintonR.D
624MikeGravelNaND
716MikeHuckabeeNaNR
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party\n", + "2 34 Hillary Clinton R. D\n", + "6 24 Mike Gravel NaN D\n", + "7 16 Mike Huckabee NaN R" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand[dfcand.first_name.isin(['Mike', 'Hillary'])]" + ] + }, + { + "cell_type": "markdown", + "id": "55a51695", + "metadata": {}, + "source": [ + "## Exercises\n", + "\n", + "1. Use `pandas` to populate the `contributors` table and display the populated `SQL` table\n", + "2. Query the `contributors` tables with the following:\n", + " 1. List entries where the state is \"VA\" and the amount is less than\n", + " $\\$400.00$.\n", + " 2. List entries where the state is \"NULL\".\n", + " 3. List entries for the states of Texas and Pennsylvania.\n", + " 4. List entries where the amount contributed is between $\\$10.00$ and\n", + " $\\$50.00$." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "4157efa1-bbaf-408d-b723-acddfe4e2ab9", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
0AgeeStevenNaN549 Laurel Branch RoadNaNFloydVA24091500.02007-06-3016
1AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA94566250.02007-05-1616
2AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA9456650.02007-06-1816
3AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA94566100.02007-06-2116
4AkinCharlesNaN10187 Sugar Creek RoadNaNBentonvilleAR72712100.02007-06-1616
\n", + "
" + ], + "text/plain": [ + " last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 Agee Steven NaN 549 Laurel Branch Road NaN Floyd VA 24091 500.0 2007-06-30 16\n", + "1 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 250.0 2007-05-16 16\n", + "2 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 50.0 2007-06-18 16\n", + "3 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 100.0 2007-06-21 16\n", + "4 Akin Charles NaN 10187 Sugar Creek Road NaN Bentonville AR 72712 100.0 2007-06-16 16" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr.to_sql(\"contributors\", dbp, if_exists=\"append\", index=False)\n", + "dfcontr.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "73d0b539-8a6a-4937-b449-ccb1df1984e4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
0AgeeStevenNaN549 Laurel Branch RoadNaNFloydVA24091500.02007-06-3016
\n", + "
" + ], + "text/plain": [ + " last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 Agee Steven NaN 549 Laurel Branch Road NaN Floyd VA 24091 500.0 2007-06-30 16" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr[(dfcontr.state == \"VA\")&(dfcontr.amount > 400.00)]" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "9d4c0749-a856-4b9e-bfed-b4af832b966e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
\n", + "
" + ], + "text/plain": [ + "Empty DataFrame\n", + "Columns: [last_name, first_name, middle_name, street_1, street_2, city, state, zip, amount, date, candidate_id]\n", + "Index: []" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr[(dfcontr.state ==None)]" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "78c732eb-e71c-43e4-93b5-a343eec1c6ff", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
65BURGERTRONALDL.5723 PLUMTREE DRIVENaNDALLASTX752524926-1000.002008-03-0522
70BUCKLEYWALTERW.1635 COUNTRY ROADNaNBETHLEHEMPA180155718-100.002008-03-0522
71BUCKLEYMARJORIEB.1635 COUNTRY ROADNaNBETHLEHEMPA180155718-100.002008-03-0522
79MuseNinaJo2915 Toro Canyon RdNaNAustinTX78746-50.002008-04-2132
93RaughtPhilipM4714 Plum WayNaNPittsburghPA15201-1046.002008-04-2132
94FerraraJudithD1508 Waterford RoadNaNYardleyPA19067-1100.002008-04-2132
95JohnsonCathleenE.1003 Justin Ln Apt 2016NaNAustinTX787572648-14.762008-04-2132
132ABREUKEVINM.1305 GARDEN GLEN LANENaNPEARLANDTX77581654750.002007-09-3035
133ABREUKEVINM.1305 GARDEN GLEN LANENaNPEARLANDTX775816547150.002007-08-0935
134ABREUKEVINM.1305 GARDEN GLEN LANENaNPEARLANDTX77581654750.002007-07-1935
165ABELJOHNH.422 THOMAS STREETNaNBETHLEHEMPA180153316200.002008-01-2237
169ABERCROMBIEDENISNaN11811 WATER OAK CTNaNMAGNOLIATX773546270500.002008-01-3037
173ABRAHAMSALEMA.P.O. BOX 7NaNCANADIANTX7901400071000.002008-01-1737
174ABRAHAMSALEMA.P.O. BOX 7NaNCANADIANTX7901400071300.002008-01-3037
\n", + "
" + ], + "text/plain": [ + " last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "65 BURGERT RONALD L. 5723 PLUMTREE DRIVE NaN DALLAS TX 752524926 -1000.00 2008-03-05 22\n", + "70 BUCKLEY WALTER W. 1635 COUNTRY ROAD NaN BETHLEHEM PA 180155718 -100.00 2008-03-05 22\n", + "71 BUCKLEY MARJORIE B. 1635 COUNTRY ROAD NaN BETHLEHEM PA 180155718 -100.00 2008-03-05 22\n", + "79 Muse Nina Jo 2915 Toro Canyon Rd NaN Austin TX 78746 -50.00 2008-04-21 32\n", + "93 Raught Philip M 4714 Plum Way NaN Pittsburgh PA 15201 -1046.00 2008-04-21 32\n", + "94 Ferrara Judith D 1508 Waterford Road NaN Yardley PA 19067 -1100.00 2008-04-21 32\n", + "95 Johnson Cathleen E. 1003 Justin Ln Apt 2016 NaN Austin TX 787572648 -14.76 2008-04-21 32\n", + "132 ABREU KEVIN M. 1305 GARDEN GLEN LANE NaN PEARLAND TX 775816547 50.00 2007-09-30 35\n", + "133 ABREU KEVIN M. 1305 GARDEN GLEN LANE NaN PEARLAND TX 775816547 150.00 2007-08-09 35\n", + "134 ABREU KEVIN M. 1305 GARDEN GLEN LANE NaN PEARLAND TX 775816547 50.00 2007-07-19 35\n", + "165 ABEL JOHN H. 422 THOMAS STREET NaN BETHLEHEM PA 180153316 200.00 2008-01-22 37\n", + "169 ABERCROMBIE DENIS NaN 11811 WATER OAK CT NaN MAGNOLIA TX 773546270 500.00 2008-01-30 37\n", + "173 ABRAHAM SALEM A. P.O. BOX 7 NaN CANADIAN TX 790140007 1000.00 2008-01-17 37\n", + "174 ABRAHAM SALEM A. P.O. BOX 7 NaN CANADIAN TX 790140007 1300.00 2008-01-30 37" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr[(dfcontr.state.isin([\"TX\",\"PA\"]))]" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "48f7e904-52b0-421b-a1d2-2a3ed760d3e4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
26BucklerSteveNaN24351 Armada DrNaNDana PointCA92629130625.02007-08-1620
49HarrisonRyanNaN2247 3rd StNaNLa VerneCA91750491825.02007-07-2620
101AaronsElaineNaN481 Buck Island Rd Apt 17AAPT 17AWest YarmouthMA2673330025.02008-02-2634
140ABEGGPATRICIAT.1862 E. 5150 S.NaNSALT LAKE CITYUT84117691125.02007-09-1735
143ABEGGPATRICIAT.1862 E. 5150 S.NaNSALT LAKE CITYUT84117691125.02007-08-0635
144ABEGGPATRICIAT.1862 E. 5150 S.NaNSALT LAKE CITYUT84117691125.02007-07-1035
158ABBOPAULINEMORENCY10720 JACOB LANENaNWHITE LAKEMI48386227435.02008-01-0737
160ABAIRPETERNaN40 EVANS STREETNaNWATERTOWNMA2472215025.02008-01-0937
\n", + "
" + ], + "text/plain": [ + " last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "26 Buckler Steve NaN 24351 Armada Dr NaN Dana Point CA 926291306 25.0 2007-08-16 20\n", + "49 Harrison Ryan NaN 2247 3rd St NaN La Verne CA 917504918 25.0 2007-07-26 20\n", + "101 Aarons Elaine NaN 481 Buck Island Rd Apt 17A APT 17A West Yarmouth MA 26733300 25.0 2008-02-26 34\n", + "140 ABEGG PATRICIA T. 1862 E. 5150 S. NaN SALT LAKE CITY UT 841176911 25.0 2007-09-17 35\n", + "143 ABEGG PATRICIA T. 1862 E. 5150 S. NaN SALT LAKE CITY UT 841176911 25.0 2007-08-06 35\n", + "144 ABEGG PATRICIA T. 1862 E. 5150 S. NaN SALT LAKE CITY UT 841176911 25.0 2007-07-10 35\n", + "158 ABBO PAULINE MORENCY 10720 JACOB LANE NaN WHITE LAKE MI 483862274 35.0 2008-01-07 37\n", + "160 ABAIR PETER NaN 40 EVANS STREET NaN WATERTOWN MA 24722150 25.0 2008-01-09 37" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr[(dfcontr.amount < 50.00)&(dfcontr.amount >= 10.00)]" + ] + }, + { + "cell_type": "markdown", + "id": "0b46cc6e", + "metadata": {}, + "source": [ + "## Sorting" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "8c5a40bf", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_nameparty
033JosephBidenNaND
234HillaryClintonR.D
339ChristopherDoddJ.D
426JohnEdwardsNaND
1329BillRichardsonNaND
624MikeGravelNaND
1120BarackObamaNaND
931DennisKucinichNaND
1435MittRomneyNaNR
1232RonPaulNaNR
830DuncanHunterNaNR
1538TomTancredoNaNR
716MikeHuckabeeNaNR
522RudolphGiulianiNaNR
136SamuelBrownbackNaNR
1037JohnMcCainNaNR
1641FredThompsonD.R
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party\n", + "0 33 Joseph Biden NaN D\n", + "2 34 Hillary Clinton R. D\n", + "3 39 Christopher Dodd J. D\n", + "4 26 John Edwards NaN D\n", + "13 29 Bill Richardson NaN D\n", + "6 24 Mike Gravel NaN D\n", + "11 20 Barack Obama NaN D\n", + "9 31 Dennis Kucinich NaN D\n", + "14 35 Mitt Romney NaN R\n", + "12 32 Ron Paul NaN R\n", + "8 30 Duncan Hunter NaN R\n", + "15 38 Tom Tancredo NaN R\n", + "7 16 Mike Huckabee NaN R\n", + "5 22 Rudolph Giuliani NaN R\n", + "1 36 Samuel Brownback NaN R\n", + "10 37 John McCain NaN R\n", + "16 41 Fred Thompson D. R" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand.sort_values(by='party')" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "499d7aa0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_nameparty
830DuncanHunterNaNR
716MikeHuckabeeNaNR
1538TomTancredoNaNR
1435MittRomneyNaNR
1232RonPaulNaNR
1037JohnMcCainNaNR
136SamuelBrownbackNaNR
1641FredThompsonD.R
522RudolphGiulianiNaNR
624MikeGravelNaND
931DennisKucinichNaND
1120BarackObamaNaND
426JohnEdwardsNaND
1329BillRichardsonNaND
339ChristopherDoddJ.D
234HillaryClintonR.D
033JosephBidenNaND
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party\n", + "8 30 Duncan Hunter NaN R\n", + "7 16 Mike Huckabee NaN R\n", + "15 38 Tom Tancredo NaN R\n", + "14 35 Mitt Romney NaN R\n", + "12 32 Ron Paul NaN R\n", + "10 37 John McCain NaN R\n", + "1 36 Samuel Brownback NaN R\n", + "16 41 Fred Thompson D. R\n", + "5 22 Rudolph Giuliani NaN R\n", + "6 24 Mike Gravel NaN D\n", + "9 31 Dennis Kucinich NaN D\n", + "11 20 Barack Obama NaN D\n", + "4 26 John Edwards NaN D\n", + "13 29 Bill Richardson NaN D\n", + "3 39 Christopher Dodd J. D\n", + "2 34 Hillary Clinton R. D\n", + "0 33 Joseph Biden NaN D" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand.sort_values(by='party', ascending=False)" + ] + }, + { + "cell_type": "markdown", + "id": "4364b1bc", + "metadata": {}, + "source": [ + "## Selecting Columns" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "baf9374f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_nameparty
0BidenD
1BrownbackR
2ClintonD
3DoddD
4EdwardsD
5GiulianiR
6GravelD
7HuckabeeR
8HunterR
9KucinichD
10McCainR
11ObamaD
12PaulR
13RichardsonD
14RomneyR
15TancredoR
16ThompsonR
\n", + "
" + ], + "text/plain": [ + " last_name party\n", + "0 Biden D\n", + "1 Brownback R\n", + "2 Clinton D\n", + "3 Dodd D\n", + "4 Edwards D\n", + "5 Giuliani R\n", + "6 Gravel D\n", + "7 Huckabee R\n", + "8 Hunter R\n", + "9 Kucinich D\n", + "10 McCain R\n", + "11 Obama D\n", + "12 Paul R\n", + "13 Richardson D\n", + "14 Romney R\n", + "15 Tancredo R\n", + "16 Thompson R" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand[['last_name', 'party']]" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "e1232473", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "last_name 17\n", + "party 17\n", + "dtype: int64" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand[['last_name', 'party']].count()" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "cfd06fa6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
first_name
0Joseph
1Samuel
2Hillary
3Christopher
4John
5Rudolph
6Mike
8Duncan
9Dennis
11Barack
12Ron
13Bill
14Mitt
15Tom
16Fred
\n", + "
" + ], + "text/plain": [ + " first_name\n", + "0 Joseph\n", + "1 Samuel\n", + "2 Hillary\n", + "3 Christopher\n", + "4 John\n", + "5 Rudolph\n", + "6 Mike\n", + "8 Duncan\n", + "9 Dennis\n", + "11 Barack\n", + "12 Ron\n", + "13 Bill\n", + "14 Mitt\n", + "15 Tom\n", + "16 Fred" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand[['first_name']].drop_duplicates()" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "830863f8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "first_name 15\n", + "dtype: int64" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand[['first_name']].drop_duplicates().count()" + ] + }, + { + "cell_type": "markdown", + "id": "1a5e16fa", + "metadata": {}, + "source": [ + "## Exercises\n", + "\n", + "1. Sort the contributors table by `amount` and order in *descending* order.\n", + "2. Select the `first_name` and `amount` columns.\n", + "3. Select the `last_name` and `first_name` columns and drop duplicates.\n", + "4. Count how many there are after the duplicates have been dropped." + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "8abb26a2-463d-4af8-b741-077c11435bed", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
30BuckelLindaNaNPO Box 683130NaNPark CityUT8406831304600.02007-08-1420
159ABATEMARIAELENA1291 NIGHTINGALE AVENUENaNMIAMI SPRINGSFL3316638322600.02008-01-2537
15AnthonyJohnNaN211 Long Island DriveNaNHot SpringsAR719132300.02007-06-1216
33BuckBlaineM45 Eaton AveNaNCamdenME484317522300.02007-09-3020
28BuckelLindaNaNPO Box 683130NaNPark CityUT8406831302300.02007-08-1420
\n", + "
" + ], + "text/plain": [ + " last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "30 Buckel Linda NaN PO Box 683130 NaN Park City UT 840683130 4600.0 2007-08-14 20\n", + "159 ABATE MARIA ELENA 1291 NIGHTINGALE AVENUE NaN MIAMI SPRINGS FL 331663832 2600.0 2008-01-25 37\n", + "15 Anthony John NaN 211 Long Island Drive NaN Hot Springs AR 71913 2300.0 2007-06-12 16\n", + "33 Buck Blaine M 45 Eaton Ave NaN Camden ME 48431752 2300.0 2007-09-30 20\n", + "28 Buckel Linda NaN PO Box 683130 NaN Park City UT 840683130 2300.0 2007-08-14 20" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr.sort_values(by='amount', ascending=False).head()" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "35ef1a9f-0843-4b23-9fe9-e03dc6042c54", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
first_nameamount
0Steven500.0
1Don250.0
2Don50.0
3Don100.0
4Charles100.0
\n", + "
" + ], + "text/plain": [ + " first_name amount\n", + "0 Steven 500.0\n", + "1 Don 250.0\n", + "2 Don 50.0\n", + "3 Don 100.0\n", + "4 Charles 100.0" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr[[\"first_name\", \"amount\"]].head()" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "6618da24-48ba-4f60-813e-18aa3ee186b1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
first_namelast_name
0StevenAgee
1DonAhrens
4CharlesAkin
5MikeAkin
6RebeccaAkin
\n", + "
" + ], + "text/plain": [ + " first_name last_name\n", + "0 Steven Agee\n", + "1 Don Ahrens\n", + "4 Charles Akin\n", + "5 Mike Akin\n", + "6 Rebecca Akin" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr[[\"first_name\", \"last_name\"]].drop_duplicates().head()" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "efe25dc7-4928-40b1-adb2-0307a5238071", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "first_name 126\n", + "last_name 126\n", + "dtype: int64" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr[[\"first_name\", \"last_name\"]].drop_duplicates().count()" + ] + }, + { + "cell_type": "markdown", + "id": "89e753b0", + "metadata": {}, + "source": [ + "## Altering Tables" + ] + }, + { + "cell_type": "markdown", + "id": "dc563f80", + "metadata": {}, + "source": [ + "Creating a new column is quite easy with `pandas`." + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "2c565bc3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_namepartyname
033JosephBidenNaNDBiden, Joseph
136SamuelBrownbackNaNRBrownback, Samuel
234HillaryClintonR.DClinton, Hillary
339ChristopherDoddJ.DDodd, Christopher
426JohnEdwardsNaNDEdwards, John
522RudolphGiulianiNaNRGiuliani, Rudolph
624MikeGravelNaNDGravel, Mike
716MikeHuckabeeNaNRHuckabee, Mike
830DuncanHunterNaNRHunter, Duncan
931DennisKucinichNaNDKucinich, Dennis
1037JohnMcCainNaNRMcCain, John
1120BarackObamaNaNDObama, Barack
1232RonPaulNaNRPaul, Ron
1329BillRichardsonNaNDRichardson, Bill
1435MittRomneyNaNRRomney, Mitt
1538TomTancredoNaNRTancredo, Tom
1641FredThompsonD.RThompson, Fred
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party name\n", + "0 33 Joseph Biden NaN D Biden, Joseph\n", + "1 36 Samuel Brownback NaN R Brownback, Samuel\n", + "2 34 Hillary Clinton R. D Clinton, Hillary\n", + "3 39 Christopher Dodd J. D Dodd, Christopher\n", + "4 26 John Edwards NaN D Edwards, John\n", + "5 22 Rudolph Giuliani NaN R Giuliani, Rudolph\n", + "6 24 Mike Gravel NaN D Gravel, Mike\n", + "7 16 Mike Huckabee NaN R Huckabee, Mike\n", + "8 30 Duncan Hunter NaN R Hunter, Duncan\n", + "9 31 Dennis Kucinich NaN D Kucinich, Dennis\n", + "10 37 John McCain NaN R McCain, John\n", + "11 20 Barack Obama NaN D Obama, Barack\n", + "12 32 Ron Paul NaN R Paul, Ron\n", + "13 29 Bill Richardson NaN D Richardson, Bill\n", + "14 35 Mitt Romney NaN R Romney, Mitt\n", + "15 38 Tom Tancredo NaN R Tancredo, Tom\n", + "16 41 Fred Thompson D. R Thompson, Fred" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand['name'] = dfcand['last_name'] + \", \" + dfcand['first_name']\n", + "dfcand" + ] + }, + { + "cell_type": "markdown", + "id": "6933f2cd", + "metadata": {}, + "source": [ + "We can change an existing field as well." + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "beed2150", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6 Gravel, Mike\n", + "7 Huckabee, Mike\n", + "Name: name, dtype: object" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand.loc[dfcand.first_name == \"Mike\", \"name\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "07415edc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_namepartyname
033JosephBidenNaNDBiden, Joseph
136SamuelBrownbackNaNRBrownback, Samuel
234HillaryClintonR.DClinton, Hillary
339ChristopherDoddJ.DDodd, Christopher
426JohnEdwardsNaNDEdwards, John
522RudolphGiulianiNaNRGiuliani, Rudolph
624MikeGravelNaNDMikey
716MikeHuckabeeNaNRMikey
830DuncanHunterNaNRHunter, Duncan
931DennisKucinichNaNDKucinich, Dennis
1037JohnMcCainNaNRMcCain, John
1120BarackObamaNaNDObama, Barack
1232RonPaulNaNRPaul, Ron
1329BillRichardsonNaNDRichardson, Bill
1435MittRomneyNaNRRomney, Mitt
1538TomTancredoNaNRTancredo, Tom
1641FredThompsonD.RThompson, Fred
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party name\n", + "0 33 Joseph Biden NaN D Biden, Joseph\n", + "1 36 Samuel Brownback NaN R Brownback, Samuel\n", + "2 34 Hillary Clinton R. D Clinton, Hillary\n", + "3 39 Christopher Dodd J. D Dodd, Christopher\n", + "4 26 John Edwards NaN D Edwards, John\n", + "5 22 Rudolph Giuliani NaN R Giuliani, Rudolph\n", + "6 24 Mike Gravel NaN D Mikey\n", + "7 16 Mike Huckabee NaN R Mikey\n", + "8 30 Duncan Hunter NaN R Hunter, Duncan\n", + "9 31 Dennis Kucinich NaN D Kucinich, Dennis\n", + "10 37 John McCain NaN R McCain, John\n", + "11 20 Barack Obama NaN D Obama, Barack\n", + "12 32 Ron Paul NaN R Paul, Ron\n", + "13 29 Bill Richardson NaN D Richardson, Bill\n", + "14 35 Mitt Romney NaN R Romney, Mitt\n", + "15 38 Tom Tancredo NaN R Tancredo, Tom\n", + "16 41 Fred Thompson D. R Thompson, Fred" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand.loc[dfcand.first_name == \"Mike\", \"name\"] = \"Mikey\"\n", + "dfcand" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "c8f5ce9c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_namepartyname
033JosephBidenNaNDBiden, Joseph
136SamuelBrownbackNaNRBrownback, Samuel
234HillaryClintonR.DClinton, Hillary
339ChristopherDoddJ.DDodd, Christopher
426JohnEdwardsNaNDEdwards, John
522RudolphGiulianiNaNRGiuliani, Rudolph
624MikeGravelNaNDMikey
716MikeHuckabeeNaNRMikey
830DuncanHunterNaNRHunter, Duncan
931DennisKucinichNaNDKucinich, Dennis
1037JohnMcCainNaNRMcCain, John
1120BarackObamaNaNDObama, Barack
1232RonPaulNaNRPaul, Ron
1329BillRichardsonNaNDRichardson, Bill
1435MittRomneyNaNRRomney, Mitt
1538TomTancredoNaNRTancredo, Tom
1641FredThompsonD.RThompson, Fred
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party name\n", + "0 33 Joseph Biden NaN D Biden, Joseph\n", + "1 36 Samuel Brownback NaN R Brownback, Samuel\n", + "2 34 Hillary Clinton R. D Clinton, Hillary\n", + "3 39 Christopher Dodd J. D Dodd, Christopher\n", + "4 26 John Edwards NaN D Edwards, John\n", + "5 22 Rudolph Giuliani NaN R Giuliani, Rudolph\n", + "6 24 Mike Gravel NaN D Mikey\n", + "7 16 Mike Huckabee NaN R Mikey\n", + "8 30 Duncan Hunter NaN R Hunter, Duncan\n", + "9 31 Dennis Kucinich NaN D Kucinich, Dennis\n", + "10 37 John McCain NaN R McCain, John\n", + "11 20 Barack Obama NaN D Obama, Barack\n", + "12 32 Ron Paul NaN R Paul, Ron\n", + "13 29 Bill Richardson NaN D Richardson, Bill\n", + "14 35 Mitt Romney NaN R Romney, Mitt\n", + "15 38 Tom Tancredo NaN R Tancredo, Tom\n", + "16 41 Fred Thompson D. R Thompson, Fred" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand.query(\"first_name == 'Mike'\")\n", + "dfcand" + ] + }, + { + "cell_type": "markdown", + "id": "0c1ef2e3", + "metadata": {}, + "source": [ + "You may recall that `SQLite` doesn't have the functionality to drop a column.\n", + "It can be done with one line using `pandas`:" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "5055a447", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_nameparty
033JosephBidenNaND
136SamuelBrownbackNaNR
234HillaryClintonR.D
339ChristopherDoddJ.D
426JohnEdwardsNaND
522RudolphGiulianiNaNR
624MikeGravelNaND
716MikeHuckabeeNaNR
830DuncanHunterNaNR
931DennisKucinichNaND
1037JohnMcCainNaNR
1120BarackObamaNaND
1232RonPaulNaNR
1329BillRichardsonNaND
1435MittRomneyNaNR
1538TomTancredoNaNR
1641FredThompsonD.R
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party\n", + "0 33 Joseph Biden NaN D\n", + "1 36 Samuel Brownback NaN R\n", + "2 34 Hillary Clinton R. D\n", + "3 39 Christopher Dodd J. D\n", + "4 26 John Edwards NaN D\n", + "5 22 Rudolph Giuliani NaN R\n", + "6 24 Mike Gravel NaN D\n", + "7 16 Mike Huckabee NaN R\n", + "8 30 Duncan Hunter NaN R\n", + "9 31 Dennis Kucinich NaN D\n", + "10 37 John McCain NaN R\n", + "11 20 Barack Obama NaN D\n", + "12 32 Ron Paul NaN R\n", + "13 29 Bill Richardson NaN D\n", + "14 35 Mitt Romney NaN R\n", + "15 38 Tom Tancredo NaN R\n", + "16 41 Fred Thompson D. R" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "del dfcand['name']\n", + "dfcand" + ] + }, + { + "cell_type": "markdown", + "id": "d8843e4a", + "metadata": {}, + "source": [ + "## Exercises\n", + "\n", + "1. Create a `name` column for the `contributors` table with field entries of the\n", + " form \"last name, first name\"\n", + "2. For contributors from the state of \"PA\", change `name` to \"X\".\n", + "3. Delete the newly created name column." + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "5cfa03ca-2559-4bc4-b181-af82ded7f566", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_idname
0AgeeStevenNaN549 Laurel Branch RoadNaNFloydVA24091500.02007-06-3016Agee, Steven
1AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA94566250.02007-05-1616Ahrens, Don
2AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA9456650.02007-06-1816Ahrens, Don
3AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA94566100.02007-06-2116Ahrens, Don
4AkinCharlesNaN10187 Sugar Creek RoadNaNBentonvilleAR72712100.02007-06-1616Akin, Charles
\n", + "
" + ], + "text/plain": [ + " last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id name\n", + "0 Agee Steven NaN 549 Laurel Branch Road NaN Floyd VA 24091 500.0 2007-06-30 16 Agee, Steven\n", + "1 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 250.0 2007-05-16 16 Ahrens, Don\n", + "2 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 50.0 2007-06-18 16 Ahrens, Don\n", + "3 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 100.0 2007-06-21 16 Ahrens, Don\n", + "4 Akin Charles NaN 10187 Sugar Creek Road NaN Bentonville AR 72712 100.0 2007-06-16 16 Akin, Charles" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr['name'] = dfcontr['last_name'] + \", \" + dfcontr['first_name']\n", + "dfcontr.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "c82916b9-8662-4ae7-983f-c59a45448099", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_idname
70BUCKLEYWALTERW.1635 COUNTRY ROADNaNBETHLEHEMPA180155718-100.02008-03-0522X
71BUCKLEYMARJORIEB.1635 COUNTRY ROADNaNBETHLEHEMPA180155718-100.02008-03-0522X
93RaughtPhilipM4714 Plum WayNaNPittsburghPA15201-1046.02008-04-2132X
94FerraraJudithD1508 Waterford RoadNaNYardleyPA19067-1100.02008-04-2132X
165ABELJOHNH.422 THOMAS STREETNaNBETHLEHEMPA180153316200.02008-01-2237X
\n", + "
" + ], + "text/plain": [ + " last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id name\n", + "70 BUCKLEY WALTER W. 1635 COUNTRY ROAD NaN BETHLEHEM PA 180155718 -100.0 2008-03-05 22 X\n", + "71 BUCKLEY MARJORIE B. 1635 COUNTRY ROAD NaN BETHLEHEM PA 180155718 -100.0 2008-03-05 22 X\n", + "93 Raught Philip M 4714 Plum Way NaN Pittsburgh PA 15201 -1046.0 2008-04-21 32 X\n", + "94 Ferrara Judith D 1508 Waterford Road NaN Yardley PA 19067 -1100.0 2008-04-21 32 X\n", + "165 ABEL JOHN H. 422 THOMAS STREET NaN BETHLEHEM PA 180153316 200.0 2008-01-22 37 X" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr.loc[dfcontr.state == \"PA\", \"name\"] = \"X\"\n", + "dfcontr.loc[dfcontr.state == \"PA\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "59fa67a8-854e-4403-8feb-5e01a8ba3ce1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
0AgeeStevenNaN549 Laurel Branch RoadNaNFloydVA24091500.02007-06-3016
1AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA94566250.02007-05-1616
2AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA9456650.02007-06-1816
3AhrensDonNaN4034 Rennellwood WayNaNPleasantonCA94566100.02007-06-2116
4AkinCharlesNaN10187 Sugar Creek RoadNaNBentonvilleAR72712100.02007-06-1616
\n", + "
" + ], + "text/plain": [ + " last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "0 Agee Steven NaN 549 Laurel Branch Road NaN Floyd VA 24091 500.0 2007-06-30 16\n", + "1 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 250.0 2007-05-16 16\n", + "2 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 50.0 2007-06-18 16\n", + "3 Ahrens Don NaN 4034 Rennellwood Way NaN Pleasanton CA 94566 100.0 2007-06-21 16\n", + "4 Akin Charles NaN 10187 Sugar Creek Road NaN Bentonville AR 72712 100.0 2007-06-16 16" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "del dfcontr['name']\n", + "dfcontr.head()" + ] + }, + { + "cell_type": "markdown", + "id": "b0080e20", + "metadata": {}, + "source": [ + "## Aggregation\n", + "\n", + "We'd like to get information about the tables such as the maximum amount\n", + "contributed to the candidates. Basic statistics on a `pandas` frame can be\n", + "obtained using the `describe()` method:" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "66937b4b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
id
count17.000000
mean30.764706
std7.110990
min16.000000
25%26.000000
50%32.000000
75%36.000000
max41.000000
\n", + "
" + ], + "text/plain": [ + " id\n", + "count 17.000000\n", + "mean 30.764706\n", + "std 7.110990\n", + "min 16.000000\n", + "25% 26.000000\n", + "50% 32.000000\n", + "75% 36.000000\n", + "max 41.000000" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand.describe()" + ] + }, + { + "cell_type": "markdown", + "id": "4bfe4c7f", + "metadata": {}, + "source": [ + "It's not very interesting with the candidates table because the candidates table\n", + "only has one numeric column. Here are a few more data queries using the\n", + "contributors table:" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "dfecf3cf", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4600.0" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr.amount.max()" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "7b148b1d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_namefirst_namemiddle_namestreet_1street_2citystatezipamountdatecandidate_id
30BuckelLindaNaNPO Box 683130NaNPark CityUT8406831304600.02007-08-1420
\n", + "
" + ], + "text/plain": [ + " last_name first_name middle_name street_1 street_2 city state zip amount date candidate_id\n", + "30 Buckel Linda NaN PO Box 683130 NaN Park City UT 840683130 4600.0 2007-08-14 20" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr[dfcontr.amount==dfcontr.amount.max()]" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "6515bac7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
zipamountcandidate_id
state
AK29854596211210.00111
AR86479014200.00192
AZ860011121120.0037
CA14736360720-5013.73600
CO2405477834-5823.00111
CT689013762300.0035
DC800341853-1549.91102
FL8970626520-4050.00803
IA50266250.0016
ID83648-261.0032
IL3042068689-5586.80175
KS66215-330.0032
KY402597029-200.0022
LA14060433271300.0074
MA123026638-83.00208
MD416287617300.0055
ME1656471702520.00122
MI2426973485-1265.00164
MN1102338918322.00100
MO64111100.0020
NC27502500.0016
NH32564424-24.6032
NJ70254993-817.4564
NV3575889763725.00144
NY606129991-6474.50233
OH176071450.0080
OK2202499044800.00102
PA540499020-2146.00145
RI58065892200.0070
SC2962147892400.0069
TN37188-25.0032
TX62214522451985.24302
UT92511533945050.00340
VA440691831515.92135
WA2941290251-500.0090
\n", + "
" + ], + "text/plain": [ + " zip amount candidate_id\n", + "state \n", + "AK 2985459621 1210.00 111\n", + "AR 864790 14200.00 192\n", + "AZ 860011121 120.00 37\n", + "CA 14736360720 -5013.73 600\n", + "CO 2405477834 -5823.00 111\n", + "CT 68901376 2300.00 35\n", + "DC 800341853 -1549.91 102\n", + "FL 8970626520 -4050.00 803\n", + "IA 50266 250.00 16\n", + "ID 83648 -261.00 32\n", + "IL 3042068689 -5586.80 175\n", + "KS 66215 -330.00 32\n", + "KY 402597029 -200.00 22\n", + "LA 1406043327 1300.00 74\n", + "MA 123026638 -83.00 208\n", + "MD 416287617 300.00 55\n", + "ME 165647170 2520.00 122\n", + "MI 2426973485 -1265.00 164\n", + "MN 1102338918 322.00 100\n", + "MO 64111 100.00 20\n", + "NC 27502 500.00 16\n", + "NH 32564424 -24.60 32\n", + "NJ 70254993 -817.45 64\n", + "NV 3575889763 725.00 144\n", + "NY 606129991 -6474.50 233\n", + "OH 176071 450.00 80\n", + "OK 2202499044 800.00 102\n", + "PA 540499020 -2146.00 145\n", + "RI 58065892 200.00 70\n", + "SC 296214789 2400.00 69\n", + "TN 37188 -25.00 32\n", + "TX 6221452245 1985.24 302\n", + "UT 9251153394 5050.00 340\n", + "VA 440691831 515.92 135\n", + "WA 2941290251 -500.00 90" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr.groupby(\"state\").sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "id": "3759b090", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "state\n", + "AK 1210.00\n", + "AR 14200.00\n", + "AZ 120.00\n", + "CA -5013.73\n", + "CO -5823.00\n", + "CT 2300.00\n", + "DC -1549.91\n", + "FL -4050.00\n", + "IA 250.00\n", + "ID -261.00\n", + "IL -5586.80\n", + "KS -330.00\n", + "KY -200.00\n", + "LA 1300.00\n", + "MA -83.00\n", + "MD 300.00\n", + "ME 2520.00\n", + "MI -1265.00\n", + "MN 322.00\n", + "MO 100.00\n", + "NC 500.00\n", + "NH -24.60\n", + "NJ -817.45\n", + "NV 725.00\n", + "NY -6474.50\n", + "OH 450.00\n", + "OK 800.00\n", + "PA -2146.00\n", + "RI 200.00\n", + "SC 2400.00\n", + "TN -25.00\n", + "TX 1985.24\n", + "UT 5050.00\n", + "VA 515.92\n", + "WA -500.00\n", + "Name: amount, dtype: float64" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr.groupby(\"state\")[\"amount\"].sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "a6a0175d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['VA', 'CA', 'AR', 'DC', 'SC', 'IA', 'OH', 'NC', 'UT', 'MO', 'IL',\n", + " 'ME', 'FL', 'MD', 'MI', 'CO', 'WA', 'NY', 'TX', 'KY', 'PA', 'TN',\n", + " 'MA', 'MN', 'KS', 'NJ', 'NH', 'ID', 'OK', nan, 'NV', 'CT', 'RI',\n", + " 'AK', 'LA', 'AZ'], dtype=object)" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr.state.unique()" + ] + }, + { + "cell_type": "markdown", + "id": "c727e2fd", + "metadata": {}, + "source": [ + "There is also a version of the `LIMIT` clause in `SQL`. It's very intuitive\n", + "using `pandas` in `python`:" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "id": "3c2b94df", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idfirst_namelast_namemiddle_nameparty
033JosephBidenNaND
136SamuelBrownbackNaNR
234HillaryClintonR.D
\n", + "
" + ], + "text/plain": [ + " id first_name last_name middle_name party\n", + "0 33 Joseph Biden NaN D\n", + "1 36 Samuel Brownback NaN R\n", + "2 34 Hillary Clinton R. D" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcand[0:3]" + ] + }, + { + "cell_type": "markdown", + "id": "0b61964d", + "metadata": {}, + "source": [ + "The usual `python` slicing works just fine!\n" + ] + }, + { + "cell_type": "markdown", + "id": "9b1c9e3d", + "metadata": {}, + "source": [ + "## Exercise\n", + "\n", + "Use the `describe()` method on the `contributors` table." + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "bece968d-d735-4a2b-b1c9-9487f85bd56c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
zipamountcandidate_id
count1.750000e+02175.000000175.000000
mean3.780014e+083.41811428.000000
std3.628278e+081028.4189997.823484
min2.474000e+03-2592.00000016.000000
25%9.336700e+04-175.00000020.000000
50%3.233313e+08100.00000032.000000
75%7.816946e+08300.00000035.000000
max9.951532e+084600.00000037.000000
\n", + "
" + ], + "text/plain": [ + " zip amount candidate_id\n", + "count 1.750000e+02 175.000000 175.000000\n", + "mean 3.780014e+08 3.418114 28.000000\n", + "std 3.628278e+08 1028.418999 7.823484\n", + "min 2.474000e+03 -2592.000000 16.000000\n", + "25% 9.336700e+04 -175.000000 20.000000\n", + "50% 3.233313e+08 100.000000 32.000000\n", + "75% 7.816946e+08 300.000000 35.000000\n", + "max 9.951532e+08 4600.000000 37.000000" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr.describe()" + ] + }, + { + "cell_type": "markdown", + "id": "cc537cb1", + "metadata": {}, + "source": [ + "## Joins with `pandas`" + ] + }, + { + "cell_type": "markdown", + "id": "5d6a729a", + "metadata": {}, + "source": [ + "`pandas` has some some documentation on `joins`: [Merge, join, and\n", + "concatenate](http://pandas.pydata.org/pandas-docs/stable/merging.html). If you\n", + "want some more reinforcement on the concepts from earlier regarding `JOIN`, then\n", + "the `pandas` documentation may be a good place to get it.\n", + "\n", + "You may also be interested in [a comparison with\n", + "`SQL`](http://pandas.pydata.org/pandas-docs/stable/comparison_with_sql.html#compare-with-sql-join).\n", + "\n", + "> To do joins with `pandas`, we use the `merge` method.\n", + "\n", + "Here's an example of an explicit inner join:" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "id": "7f956838", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
last_name_xfirst_name_xcandidate_ididlast_name_yamount
0AgeeSteven1616Huckabee500.00
1AhrensDon1616Huckabee250.00
2AhrensDon1616Huckabee50.00
3AhrensDon1616Huckabee100.00
4AkinCharles1616Huckabee100.00
5AkinMike1616Huckabee1500.00
6AkinRebecca1616Huckabee500.00
7AldridgeBrittni1616Huckabee250.00
8AllenJohn D.1616Huckabee1000.00
9AllenJohn D.1616Huckabee1300.00
10AllisonJohn W.1616Huckabee1000.00
11AllisonRebecca1616Huckabee1000.00
12AllisonRebecca1616Huckabee200.00
13AltesR.D.1616Huckabee2300.00
14AndresDale1616Huckabee250.00
15AnthonyJohn1616Huckabee2300.00
16ArbogastRobert1616Huckabee500.00
17ArbogastRobert1616Huckabee100.00
18ArdleWilliam1616Huckabee50.00
19AtiqOmar1616Huckabee1000.00
20AtiqOmar1616Huckabee1000.00
21BakerDavid1616Huckabee2300.00
22BancroftDavid1616Huckabee250.00
23BanksCharles1616Huckabee1000.00
24BarbeeJohn1616Huckabee500.00
25BucklerSteve2020Obama50.00
26BucklerSteve2020Obama25.00
27BuckheitBruce2020Obama100.00
28BuckelLinda2020Obama2300.00
29BuckelLinda2020Obama-2300.00
30BuckelLinda2020Obama4600.00
31BuckThomas2020Obama100.00
32BuckJay2020Obama200.00
33BuckBlaine2020Obama2300.00
34BuckBarbara2020Obama50.00
35BuckBarbara2020Obama50.00
36BuchmanMark M2020Obama460.80
37BucherIda2020Obama100.00
38BuchanekElizabeth2020Obama50.00
39BuchananJohn2020Obama500.00
40BuchananJohn2020Obama-500.00
41BuchananJohn2020Obama500.00
42BuchananJohn2020Obama700.00
43BuchananJohn2020Obama-700.00
44BuchananJohn2020Obama1000.00
45BuchananJohn2020Obama1300.00
46BuchananJohn2020Obama200.00
47BuchananJohn2020Obama500.00
48BuchananJohn2020Obama200.09
49HarrisonRyan2020Obama25.00
50BYNUMHERBERT2222Giuliani-500.00
51BYINGTONMARGARET2222Giuliani-2300.00
52BYERSBOB2222Giuliani-2300.00
53BYERSAUDREY2222Giuliani-200.00
54BUSHKRYSTIE2222Giuliani-2300.00
55BUSHERIC2222Giuliani-2300.00
56BURTONSUSAN2222Giuliani-2300.00
57BURTONSTEVEN2222Giuliani-2300.00
58BURTONGLENN2222Giuliani-2300.00
59BURKHARDTCRAIG2222Giuliani-500.00
60BURKHARDTCRAIG2222Giuliani-1000.00
61BURKHARDTBARBARA2222Giuliani-500.00
62BURKESUZANNE2222Giuliani-700.00
63BURKEGAIL2222Giuliani-2000.00
64BURKEDONALD2222Giuliani-2300.00
65BURGERTRONALD2222Giuliani-1000.00
66BULLBARTLE2222Giuliani-800.00
67BULLBARTLE2222Giuliani-1000.00
68BUKOWSKIDANIEL2222Giuliani-100.00
69BUISSONMARGARET2222Giuliani-200.00
70BUCKLEYWALTER2222Giuliani-100.00
71BUCKLEYMARJORIE2222Giuliani-100.00
72BRUNOJOHN2222Giuliani-2300.00
73BRUNOIRENE2222Giuliani-2300.00
74BROWNTIMOTHY2222Giuliani-2300.00
75SchuffBryan3232Paul-25.00
76HobbsJames3232Paul-25.00
77RanganathAnoop3232Paul-100.00
78NystromMichael3232Paul-503.00
79MuseNina3232Paul-50.00
80WaddellJames3232Paul-28.00
81BrucksWilliam3232Paul-150.00
82KuehnDavid3232Paul-330.00
83VersterJeanette3232Paul-1000.00
84UihleinRichard3232Paul-2300.00
85EskenberryRobert3232Paul-223.00
86FroehlingAlan3232Paul-844.80
87DuryeaMarcia3232Paul-299.50
88PerreaultLouise3232Paul-34.08
89RozenfeldTimur3232Paul-777.95
90KazorChristopher3232Paul-2592.00
91LehnerThomas3232Paul-200.00
92PlummerJoseph3232Paul-24.60
93RaughtPhilip3232Paul-1046.00
94FerraraJudith3232Paul-1100.00
95JohnsonCathleen3232Paul-14.76
96SanfordBradley3232Paul-24.53
97GaarderBruce3232Paul-261.00
98ChoeHyeokchan3232Paul-39.50
99JacobsRichard3232Paul-1000.00
100AaronsonRebecca3434Clinton100.00
101AaronsElaine3434Clinton25.00
102AaronsElaine3434Clinton70.00
103AaronsElaine3434Clinton100.00
104AaronShirley3434Clinton50.00
105AaronShirley3434Clinton100.00
106AaronsonRebecca3434Clinton100.00
107AaronShirley3434Clinton100.00
108AaronShirley3434Clinton100.00
109AaronShirley3434Clinton100.00
110ReidElizabeth3434Clinton-350.00
111ReichThomas3434Clinton-2300.00
112AaronShirley3434Clinton100.00
113AaronShirley3434Clinton100.00
114AaronSharron3434Clinton500.00
115AaronPatricia3434Clinton200.00
116AaronPatricia3434Clinton100.00
117AaronJim3434Clinton300.00
118AaronJim3434Clinton200.00
119AaronCarole3434Clinton70.00
120AaronCarole3434Clinton50.00
121AaronCarole3434Clinton100.00
122AaronBarbara3434Clinton1000.00
123AanonsenLin3434Clinton250.00
124AanonsenLin3434Clinton100.00
125BOURNETRAVIS3535Romney-500.00
126SECRISTBRIAN3535Romney-1000.00
127TOLLESTRUPTRAVIS3535Romney-1000.00
128ACCORDDEAN3535Romney500.00
129ABTSHENRY3535Romney100.00
130ABSHIERLANNY3535Romney500.00
131ABSHIERDIANA3535Romney500.00
132ABREUKEVIN3535Romney50.00
133ABREUKEVIN3535Romney150.00
134ABREUKEVIN3535Romney50.00
135ABRAMOWITZNIRA3535Romney2300.00
136ABRAMSMICHAEL3535Romney250.00
137ABRAMOWITZKEN3535Romney300.00
138ABOUBAKARENASAR3535Romney1000.00
139ABEGGPATRICIA3535Romney75.00
140ABEGGPATRICIA3535Romney25.00
141ABEGGPATRICIA3535Romney75.00
142ABEGGPATRICIA3535Romney75.00
143ABEGGPATRICIA3535Romney25.00
144ABEGGPATRICIA3535Romney25.00
145ABDELLATHOMAS3535Romney50.00
146ABBOTTWELDON3535Romney100.00
147ABBOTTWELDON3535Romney50.00
148ABBOTTGERALD3535Romney100.00
149ABBOTTGERALD3535Romney100.00
150ABEDINZAINUL3737McCain500.00
151ABBOTTSYBIL3737McCain75.00
152ABBOTTSYBIL3737McCain50.00
153ABBOTTRONALD3737McCain200.00
154ABBOTTRONALD3737McCain100.00
155ABBOTTROBERT3737McCain500.00
156ABBOTTMIKE3737McCain1000.00
157ABBOTDAVID3737McCain200.00
158ABBOPAULINE3737McCain35.00
159ABATEMARIA3737McCain2600.00
160ABAIRPETER3737McCain25.00
161ABACHERLISHIRLEY3737McCain150.00
162AARONSCHARLES3737McCain300.00
163AARONSCHARLES3737McCain410.00
164AARONSCHARLES3737McCain500.00
165ABELJOHN3737McCain200.00
166ABELMARLING3737McCain100.00
167ABELRUDOLPH3737McCain100.00
168ABELERODNEY3737McCain500.00
169ABERCROMBIEDENIS3737McCain500.00
170ABESHAUSMERRILL3737McCain120.00
171ABRAHAMGEORGE3737McCain800.00
172ABRAHAMSONPETER3737McCain50.00
173ABRAHAMSALEM3737McCain1000.00
174ABRAHAMSALEM3737McCain1300.00
\n", + "
" + ], + "text/plain": [ + " last_name_x first_name_x candidate_id id last_name_y amount\n", + "0 Agee Steven 16 16 Huckabee 500.00\n", + "1 Ahrens Don 16 16 Huckabee 250.00\n", + "2 Ahrens Don 16 16 Huckabee 50.00\n", + "3 Ahrens Don 16 16 Huckabee 100.00\n", + "4 Akin Charles 16 16 Huckabee 100.00\n", + "5 Akin Mike 16 16 Huckabee 1500.00\n", + "6 Akin Rebecca 16 16 Huckabee 500.00\n", + "7 Aldridge Brittni 16 16 Huckabee 250.00\n", + "8 Allen John D. 16 16 Huckabee 1000.00\n", + "9 Allen John D. 16 16 Huckabee 1300.00\n", + "10 Allison John W. 16 16 Huckabee 1000.00\n", + "11 Allison Rebecca 16 16 Huckabee 1000.00\n", + "12 Allison Rebecca 16 16 Huckabee 200.00\n", + "13 Altes R.D. 16 16 Huckabee 2300.00\n", + "14 Andres Dale 16 16 Huckabee 250.00\n", + "15 Anthony John 16 16 Huckabee 2300.00\n", + "16 Arbogast Robert 16 16 Huckabee 500.00\n", + "17 Arbogast Robert 16 16 Huckabee 100.00\n", + "18 Ardle William 16 16 Huckabee 50.00\n", + "19 Atiq Omar 16 16 Huckabee 1000.00\n", + "20 Atiq Omar 16 16 Huckabee 1000.00\n", + "21 Baker David 16 16 Huckabee 2300.00\n", + "22 Bancroft David 16 16 Huckabee 250.00\n", + "23 Banks Charles 16 16 Huckabee 1000.00\n", + "24 Barbee John 16 16 Huckabee 500.00\n", + "25 Buckler Steve 20 20 Obama 50.00\n", + "26 Buckler Steve 20 20 Obama 25.00\n", + "27 Buckheit Bruce 20 20 Obama 100.00\n", + "28 Buckel Linda 20 20 Obama 2300.00\n", + "29 Buckel Linda 20 20 Obama -2300.00\n", + "30 Buckel Linda 20 20 Obama 4600.00\n", + "31 Buck Thomas 20 20 Obama 100.00\n", + "32 Buck Jay 20 20 Obama 200.00\n", + "33 Buck Blaine 20 20 Obama 2300.00\n", + "34 Buck Barbara 20 20 Obama 50.00\n", + "35 Buck Barbara 20 20 Obama 50.00\n", + "36 Buchman Mark M 20 20 Obama 460.80\n", + "37 Bucher Ida 20 20 Obama 100.00\n", + "38 Buchanek Elizabeth 20 20 Obama 50.00\n", + "39 Buchanan John 20 20 Obama 500.00\n", + "40 Buchanan John 20 20 Obama -500.00\n", + "41 Buchanan John 20 20 Obama 500.00\n", + "42 Buchanan John 20 20 Obama 700.00\n", + "43 Buchanan John 20 20 Obama -700.00\n", + "44 Buchanan John 20 20 Obama 1000.00\n", + "45 Buchanan John 20 20 Obama 1300.00\n", + "46 Buchanan John 20 20 Obama 200.00\n", + "47 Buchanan John 20 20 Obama 500.00\n", + "48 Buchanan John 20 20 Obama 200.09\n", + "49 Harrison Ryan 20 20 Obama 25.00\n", + "50 BYNUM HERBERT 22 22 Giuliani -500.00\n", + "51 BYINGTON MARGARET 22 22 Giuliani -2300.00\n", + "52 BYERS BOB 22 22 Giuliani -2300.00\n", + "53 BYERS AUDREY 22 22 Giuliani -200.00\n", + "54 BUSH KRYSTIE 22 22 Giuliani -2300.00\n", + "55 BUSH ERIC 22 22 Giuliani -2300.00\n", + "56 BURTON SUSAN 22 22 Giuliani -2300.00\n", + "57 BURTON STEVEN 22 22 Giuliani -2300.00\n", + "58 BURTON GLENN 22 22 Giuliani -2300.00\n", + "59 BURKHARDT CRAIG 22 22 Giuliani -500.00\n", + "60 BURKHARDT CRAIG 22 22 Giuliani -1000.00\n", + "61 BURKHARDT BARBARA 22 22 Giuliani -500.00\n", + "62 BURKE SUZANNE 22 22 Giuliani -700.00\n", + "63 BURKE GAIL 22 22 Giuliani -2000.00\n", + "64 BURKE DONALD 22 22 Giuliani -2300.00\n", + "65 BURGERT RONALD 22 22 Giuliani -1000.00\n", + "66 BULL BARTLE 22 22 Giuliani -800.00\n", + "67 BULL BARTLE 22 22 Giuliani -1000.00\n", + "68 BUKOWSKI DANIEL 22 22 Giuliani -100.00\n", + "69 BUISSON MARGARET 22 22 Giuliani -200.00\n", + "70 BUCKLEY WALTER 22 22 Giuliani -100.00\n", + "71 BUCKLEY MARJORIE 22 22 Giuliani -100.00\n", + "72 BRUNO JOHN 22 22 Giuliani -2300.00\n", + "73 BRUNO IRENE 22 22 Giuliani -2300.00\n", + "74 BROWN TIMOTHY 22 22 Giuliani -2300.00\n", + "75 Schuff Bryan 32 32 Paul -25.00\n", + "76 Hobbs James 32 32 Paul -25.00\n", + "77 Ranganath Anoop 32 32 Paul -100.00\n", + "78 Nystrom Michael 32 32 Paul -503.00\n", + "79 Muse Nina 32 32 Paul -50.00\n", + "80 Waddell James 32 32 Paul -28.00\n", + "81 Brucks William 32 32 Paul -150.00\n", + "82 Kuehn David 32 32 Paul -330.00\n", + "83 Verster Jeanette 32 32 Paul -1000.00\n", + "84 Uihlein Richard 32 32 Paul -2300.00\n", + "85 Eskenberry Robert 32 32 Paul -223.00\n", + "86 Froehling Alan 32 32 Paul -844.80\n", + "87 Duryea Marcia 32 32 Paul -299.50\n", + "88 Perreault Louise 32 32 Paul -34.08\n", + "89 Rozenfeld Timur 32 32 Paul -777.95\n", + "90 Kazor Christopher 32 32 Paul -2592.00\n", + "91 Lehner Thomas 32 32 Paul -200.00\n", + "92 Plummer Joseph 32 32 Paul -24.60\n", + "93 Raught Philip 32 32 Paul -1046.00\n", + "94 Ferrara Judith 32 32 Paul -1100.00\n", + "95 Johnson Cathleen 32 32 Paul -14.76\n", + "96 Sanford Bradley 32 32 Paul -24.53\n", + "97 Gaarder Bruce 32 32 Paul -261.00\n", + "98 Choe Hyeokchan 32 32 Paul -39.50\n", + "99 Jacobs Richard 32 32 Paul -1000.00\n", + "100 Aaronson Rebecca 34 34 Clinton 100.00\n", + "101 Aarons Elaine 34 34 Clinton 25.00\n", + "102 Aarons Elaine 34 34 Clinton 70.00\n", + "103 Aarons Elaine 34 34 Clinton 100.00\n", + "104 Aaron Shirley 34 34 Clinton 50.00\n", + "105 Aaron Shirley 34 34 Clinton 100.00\n", + "106 Aaronson Rebecca 34 34 Clinton 100.00\n", + "107 Aaron Shirley 34 34 Clinton 100.00\n", + "108 Aaron Shirley 34 34 Clinton 100.00\n", + "109 Aaron Shirley 34 34 Clinton 100.00\n", + "110 Reid Elizabeth 34 34 Clinton -350.00\n", + "111 Reich Thomas 34 34 Clinton -2300.00\n", + "112 Aaron Shirley 34 34 Clinton 100.00\n", + "113 Aaron Shirley 34 34 Clinton 100.00\n", + "114 Aaron Sharron 34 34 Clinton 500.00\n", + "115 Aaron Patricia 34 34 Clinton 200.00\n", + "116 Aaron Patricia 34 34 Clinton 100.00\n", + "117 Aaron Jim 34 34 Clinton 300.00\n", + "118 Aaron Jim 34 34 Clinton 200.00\n", + "119 Aaron Carole 34 34 Clinton 70.00\n", + "120 Aaron Carole 34 34 Clinton 50.00\n", + "121 Aaron Carole 34 34 Clinton 100.00\n", + "122 Aaron Barbara 34 34 Clinton 1000.00\n", + "123 Aanonsen Lin 34 34 Clinton 250.00\n", + "124 Aanonsen Lin 34 34 Clinton 100.00\n", + "125 BOURNE TRAVIS 35 35 Romney -500.00\n", + "126 SECRIST BRIAN 35 35 Romney -1000.00\n", + "127 TOLLESTRUP TRAVIS 35 35 Romney -1000.00\n", + "128 ACCORD DEAN 35 35 Romney 500.00\n", + "129 ABTS HENRY 35 35 Romney 100.00\n", + "130 ABSHIER LANNY 35 35 Romney 500.00\n", + "131 ABSHIER DIANA 35 35 Romney 500.00\n", + "132 ABREU KEVIN 35 35 Romney 50.00\n", + "133 ABREU KEVIN 35 35 Romney 150.00\n", + "134 ABREU KEVIN 35 35 Romney 50.00\n", + "135 ABRAMOWITZ NIRA 35 35 Romney 2300.00\n", + "136 ABRAMS MICHAEL 35 35 Romney 250.00\n", + "137 ABRAMOWITZ KEN 35 35 Romney 300.00\n", + "138 ABOUBAKARE NASAR 35 35 Romney 1000.00\n", + "139 ABEGG PATRICIA 35 35 Romney 75.00\n", + "140 ABEGG PATRICIA 35 35 Romney 25.00\n", + "141 ABEGG PATRICIA 35 35 Romney 75.00\n", + "142 ABEGG PATRICIA 35 35 Romney 75.00\n", + "143 ABEGG PATRICIA 35 35 Romney 25.00\n", + "144 ABEGG PATRICIA 35 35 Romney 25.00\n", + "145 ABDELLA THOMAS 35 35 Romney 50.00\n", + "146 ABBOTT WELDON 35 35 Romney 100.00\n", + "147 ABBOTT WELDON 35 35 Romney 50.00\n", + "148 ABBOTT GERALD 35 35 Romney 100.00\n", + "149 ABBOTT GERALD 35 35 Romney 100.00\n", + "150 ABEDIN ZAINUL 37 37 McCain 500.00\n", + "151 ABBOTT SYBIL 37 37 McCain 75.00\n", + "152 ABBOTT SYBIL 37 37 McCain 50.00\n", + "153 ABBOTT RONALD 37 37 McCain 200.00\n", + "154 ABBOTT RONALD 37 37 McCain 100.00\n", + "155 ABBOTT ROBERT 37 37 McCain 500.00\n", + "156 ABBOTT MIKE 37 37 McCain 1000.00\n", + "157 ABBOT DAVID 37 37 McCain 200.00\n", + "158 ABBO PAULINE 37 37 McCain 35.00\n", + "159 ABATE MARIA 37 37 McCain 2600.00\n", + "160 ABAIR PETER 37 37 McCain 25.00\n", + "161 ABACHERLI SHIRLEY 37 37 McCain 150.00\n", + "162 AARONS CHARLES 37 37 McCain 300.00\n", + "163 AARONS CHARLES 37 37 McCain 410.00\n", + "164 AARONS CHARLES 37 37 McCain 500.00\n", + "165 ABEL JOHN 37 37 McCain 200.00\n", + "166 ABEL MARLING 37 37 McCain 100.00\n", + "167 ABEL RUDOLPH 37 37 McCain 100.00\n", + "168 ABELE RODNEY 37 37 McCain 500.00\n", + "169 ABERCROMBIE DENIS 37 37 McCain 500.00\n", + "170 ABESHAUS MERRILL 37 37 McCain 120.00\n", + "171 ABRAHAM GEORGE 37 37 McCain 800.00\n", + "172 ABRAHAMSON PETER 37 37 McCain 50.00\n", + "173 ABRAHAM SALEM 37 37 McCain 1000.00\n", + "174 ABRAHAM SALEM 37 37 McCain 1300.00" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cols_wanted = ['last_name_x', 'first_name_x', 'candidate_id', 'id', 'last_name_y', 'amount']\n", + "dfcontr.merge(dfcand, left_on=\"candidate_id\", right_on=\"id\")[cols_wanted]" + ] + }, + { + "cell_type": "markdown", + "id": "842f3710", + "metadata": {}, + "source": [ + "Somewhat more organized with additional grouping and description of resulting\n", + "data frame:" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "id": "7322f44e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
candidate_ididamount
countmeanstdmin25%50%75%maxcountmeanstdmin25%50%75%maxcountmeanstdmin25%50%75%max
last_name_y
Clinton25.034.00.034.034.034.034.034.025.034.00.034.034.034.034.034.025.050.6000538.764636-2300.070.0100.0100.001000.00
Giuliani25.022.00.022.022.022.022.022.025.022.00.022.022.022.022.022.025.0-1360.0000934.077085-2300.0-2300.0-1000.0-500.00-100.00
Huckabee25.016.00.016.016.016.016.016.025.016.00.016.016.016.016.016.025.0772.0000714.00863750.0250.0500.01000.002300.00
McCain25.037.00.037.037.037.037.037.025.037.00.037.037.037.037.037.025.0452.6000565.54936425.0100.0200.0500.002600.00
Obama25.020.00.020.020.020.020.020.025.020.00.020.020.020.020.020.025.0472.43561233.114920-2300.050.0200.0500.004600.00
Paul25.032.00.032.032.032.032.032.025.032.00.032.032.032.032.032.025.0-519.7088693.111403-2592.0-844.8-223.0-34.08-14.76
Romney25.035.00.035.035.035.035.035.025.035.00.035.035.035.035.035.025.0156.0000609.827503-1000.050.075.0250.002300.00
\n", + "
" + ], + "text/plain": [ + " candidate_id id amount \n", + " count mean std min 25% 50% 75% max count mean std min 25% 50% 75% max count mean std min 25% 50% 75% max\n", + "last_name_y \n", + "Clinton 25.0 34.0 0.0 34.0 34.0 34.0 34.0 34.0 25.0 34.0 0.0 34.0 34.0 34.0 34.0 34.0 25.0 50.6000 538.764636 -2300.0 70.0 100.0 100.00 1000.00\n", + "Giuliani 25.0 22.0 0.0 22.0 22.0 22.0 22.0 22.0 25.0 22.0 0.0 22.0 22.0 22.0 22.0 22.0 25.0 -1360.0000 934.077085 -2300.0 -2300.0 -1000.0 -500.00 -100.00\n", + "Huckabee 25.0 16.0 0.0 16.0 16.0 16.0 16.0 16.0 25.0 16.0 0.0 16.0 16.0 16.0 16.0 16.0 25.0 772.0000 714.008637 50.0 250.0 500.0 1000.00 2300.00\n", + "McCain 25.0 37.0 0.0 37.0 37.0 37.0 37.0 37.0 25.0 37.0 0.0 37.0 37.0 37.0 37.0 37.0 25.0 452.6000 565.549364 25.0 100.0 200.0 500.00 2600.00\n", + "Obama 25.0 20.0 0.0 20.0 20.0 20.0 20.0 20.0 25.0 20.0 0.0 20.0 20.0 20.0 20.0 20.0 25.0 472.4356 1233.114920 -2300.0 50.0 200.0 500.00 4600.00\n", + "Paul 25.0 32.0 0.0 32.0 32.0 32.0 32.0 32.0 25.0 32.0 0.0 32.0 32.0 32.0 32.0 32.0 25.0 -519.7088 693.111403 -2592.0 -844.8 -223.0 -34.08 -14.76\n", + "Romney 25.0 35.0 0.0 35.0 35.0 35.0 35.0 35.0 25.0 35.0 0.0 35.0 35.0 35.0 35.0 35.0 25.0 156.0000 609.827503 -1000.0 50.0 75.0 250.00 2300.00" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfcontr.merge(dfcand, left_on=\"candidate_id\", right_on=\"id\")[cols_wanted].groupby('last_name_y').describe()" + ] + }, + { + "cell_type": "markdown", + "id": "79bcc62c", + "metadata": {}, + "source": [ + "### Other Joins with `pandas`\n", + "\n", + "We didn't cover all possible joins because `SQLite` can only handle the few that\n", + "we did discuss. As mentioned, there are workarounds for some things in\n", + "`SQLite`, but not everything. Fortunately, `pandas` can handle pretty much\n", + "everything. Here are a few joins that `pandas` can handle:\n", + "\n", + "* `LEFT OUTER`: discussed above\n", + "* `RIGHT OUTER`: think of the \"opposite\" of a `LEFT OUTER` join (shade the\n", + " intersection and *right* set in the Venn diagram).\n", + "* `FULL OUTER`: combine everything from both tables (shade the entire Venn\n", + " diagram)\n", + "\n", + "Lets build the tables from the join exercise above in `pandas`:" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "id": "b7eea35c", + "metadata": { + "lines_to_next_cell": 2 + }, + "outputs": [], + "source": [ + "df_A = pd.DataFrame({\n", + " 'nA': ['s1', 's2', 's3', 's4'],\n", + " 'attr': [23, 7, 15, 31],\n", + " 'idA': [0, 2, 3, 7]\n", + "})\n", + "\n", + "df_B = pd.DataFrame({\n", + " 'nB': ['t1', 't2', 't3'],\n", + " 'attr': [60, 14, 22],\n", + " 'idB': [0, 7, 2]\n", + "})" + ] + }, + { + "cell_type": "markdown", + "id": "98fcc8c4", + "metadata": {}, + "source": [ + "#### Left Outer Join with `pandas`" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "a0dd2148", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
nAattr_xidAnBattr_yidB
0s1230t160.00.0
1s272t322.02.0
2s3153NaNNaNNaN
3s4317t214.07.0
\n", + "
" + ], + "text/plain": [ + " nA attr_x idA nB attr_y idB\n", + "0 s1 23 0 t1 60.0 0.0\n", + "1 s2 7 2 t3 22.0 2.0\n", + "2 s3 15 3 NaN NaN NaN\n", + "3 s4 31 7 t2 14.0 7.0" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_A.merge(df_B, left_on='idA', right_on='idB', how='left')" + ] + }, + { + "cell_type": "markdown", + "id": "862e7b92", + "metadata": {}, + "source": [ + "#### Right Outer Join with `pandas`" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "c8dd4523", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
nAattr_xidAnBattr_yidB
0s1230t1600
1s4317t2147
2s272t3222
\n", + "
" + ], + "text/plain": [ + " nA attr_x idA nB attr_y idB\n", + "0 s1 23 0 t1 60 0\n", + "1 s4 31 7 t2 14 7\n", + "2 s2 7 2 t3 22 2" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_A.merge(df_B, left_on='idA', right_on='idB', how='right')" + ] + }, + { + "cell_type": "markdown", + "id": "53eceb9e", + "metadata": {}, + "source": [ + "#### Full Outer Join with `pandas`" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "id": "531b99f2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
nAattr_xidAnBattr_yidB
0s1230t160.00.0
1s272t322.02.0
2s3153NaNNaNNaN
3s4317t214.07.0
\n", + "
" + ], + "text/plain": [ + " nA attr_x idA nB attr_y idB\n", + "0 s1 23 0 t1 60.0 0.0\n", + "1 s2 7 2 t3 22.0 2.0\n", + "2 s3 15 3 NaN NaN NaN\n", + "3 s4 31 7 t2 14.0 7.0" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_A.merge(df_B, left_on='idA', right_on='idB', how='outer')" + ] + }, + { + "cell_type": "markdown", + "id": "2c8822c6", + "metadata": {}, + "source": [ + "# Save our databases\n", + "\n", + "Commit the changes to the open `SQL` databases and close them. Well done!" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "0d994c14", + "metadata": {}, + "outputs": [], + "source": [ + "db.commit()\n", + "dbp.commit()\n", + "db.close()\n", + "dbp.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4d53cef0-950b-4470-a0fc-555bfe05fa66", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "jupytext": { + "formats": "ipynb,md" + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/lectures/lecture12/candidates.txt b/lectures/lecture12/candidates.txt new file mode 100644 index 0000000..61c7616 --- /dev/null +++ b/lectures/lecture12/candidates.txt @@ -0,0 +1,18 @@ +id|first_name|last_name|middle_name|party +33|Joseph|Biden||D +36|Samuel|Brownback||R +34|Hillary|Clinton|R.|D +39|Christopher|Dodd|J.|D +26|John|Edwards||D +22|Rudolph|Giuliani||R +24|Mike|Gravel||D +16|Mike|Huckabee||R +30|Duncan|Hunter||R +31|Dennis|Kucinich||D +37|John|McCain||R +20|Barack|Obama||D +32|Ron|Paul||R +29|Bill|Richardson||D +35|Mitt|Romney||R +38|Tom|Tancredo||R +41|Fred|Thompson|D.|R diff --git a/lectures/lecture12/contributors.txt b/lectures/lecture12/contributors.txt new file mode 100644 index 0000000..02d3ccc --- /dev/null +++ b/lectures/lecture12/contributors.txt @@ -0,0 +1,176 @@ +id|last_name|first_name|middle_name|street_1|street_2|city|state|zip|amount|date|candidate_id +|Agee|Steven||549 Laurel Branch Road||Floyd|VA|24091|500.00|2007-06-30|16 +|Ahrens|Don||4034 Rennellwood Way||Pleasanton|CA|94566|250.00|2007-05-16|16 +|Ahrens|Don||4034 Rennellwood Way||Pleasanton|CA|94566|50.00|2007-06-18|16 +|Ahrens|Don||4034 Rennellwood Way||Pleasanton|CA|94566|100.00|2007-06-21|16 +|Akin|Charles||10187 Sugar Creek Road||Bentonville|AR|72712|100.00|2007-06-16|16 +|Akin|Mike||181 Baywood Lane||Monticello|AR|71655|1500.00|2007-05-18|16 +|Akin|Rebecca||181 Baywood Lane||Monticello|AR|71655|500.00|2007-05-18|16 +|Aldridge|Brittni||808 Capitol Square Place, SW||Washington|DC|20024|250.00|2007-06-06|16 +|Allen|John D.||1052 Cannon Mill Drive||North Augusta|SC|29860|1000.00|2007-06-11|16 +|Allen|John D.||1052 Cannon Mill Drive||North Augusta|SC|29860|1300.00|2007-06-29|16 +|Allison|John W.||P.O. Box 1089||Conway|AR|72033|1000.00|2007-05-18|16 +|Allison|Rebecca||3206 Summit Court||Little Rock|AR|72227|1000.00|2007-04-25|16 +|Allison|Rebecca||3206 Summit Court||Little Rock|AR|72227|200.00|2007-06-12|16 +|Altes|R.D.||8600 Moody Road||Fort Smith|AR|72903|2300.00|2007-06-21|16 +|Andres|Dale||1160 Glen Oaks Drive||West Des Moines|IA|50266|250.00|2007-06-06|16 +|Anthony|John||211 Long Island Drive||Hot Springs|AR|71913|2300.00|2007-06-12|16 +|Arbogast|Robert||12900 State Route 56 SE||Mount Sterling|OH|43143|500.00|2007-04-08|16 +|Arbogast|Robert||12900 State Route 56 SE||Mount Sterling|OH|43143|100.00|2007-06-22|16 +|Ardle|William||412 Dakota Avenue||Springfield|OH|45504|50.00|2007-06-28|16 +|Atiq|Omar||7200 S Hazel Street||Pine Bluff|AR|71603|1000.00|2007-05-18|16 +|Atiq|Omar||7200 S Hazel Street||Pine Bluff|AR|71603|1000.00|2007-06-27|16 +|Baker|David||2550 Adamsbrooke Drive||Conway|AR|72034|2300.00|2007-04-11|16 +|Bancroft|David||2934 Broderick Street||San Francisco|CA|94123|250.00|2007-04-24|16 +|Banks|Charles||P.O. Box 251310||Little Rock|AR|72225|1000.00|2007-05-14|16 +|Barbee|John||516 Kellyridge Drive||Apex|NC|27502|500.00|2007-05-23|16 +|Buckler|Steve||24351 Armada Dr||Dana Point|CA|926291306|50.00|2007-07-30|20 +|Buckler|Steve||24351 Armada Dr||Dana Point|CA|926291306|25.00|2007-08-16|20 +|Buckheit|Bruce||8904 KAREN DR||FAIRFAX|VA|220312731|100.00|2007-09-19|20 +|Buckel|Linda||PO Box 683130||Park City|UT|840683130|2300.00|2007-08-14|20 +|Buckel|Linda||PO Box 683130||Park City|UT|840683130|-2300.00|2007-08-14|20 +|Buckel|Linda||PO Box 683130||Park City|UT|840683130|4600.00|2007-08-14|20 +|Buck|Thomas||4206 Terrace Street||Kansas City|MO|64111|100.00|2007-09-25|20 +|Buck|Jay|K.|1855 Old Willow Rd Unit 322||Northfield|IL|600932918|200.00|2007-09-12|20 +|Buck|Blaine|M|45 Eaton Ave||Camden|ME|048431752|2300.00|2007-09-30|20 +|Buck|Barbara||1780 NE 138th St||North Miami|FL|331811316|50.00|2007-09-13|20 +|Buck|Barbara||1780 NE 138th St||North Miami|FL|331811316|50.00|2007-07-19|20 +|Buchman|Mark M||2530 Lawton Ave||San Luis Obispo|CA|934015622|460.80|2007-07-18|20 +|Bucher|Ida|M|1400 Warnall Ave||Los Angeles|CA|900245333|100.00|2007-07-10|20 +|Buchanek|Elizabeth||7917 Kentbury Dr||Bethesda|MD|208144615|50.00|2007-09-30|20 +|Buchanan|John||2025 NW 29th Rd||Boca Raton|FL|334316303|500.00|2007-09-24|20 +|Buchanan|John||2025 NW 29th Rd||Boca Raton|FL|334316303|-500.00|2007-09-24|20 +|Buchanan|John||2025 NW 29th Rd||Boca Raton|FL|334316303|500.00|2007-09-24|20 +|Buchanan|John||2025 NW 29th Rd||Boca Raton|FL|334316303|700.00|2007-08-28|20 +|Buchanan|John||2025 NW 29th Rd||Boca Raton|FL|334316303|-700.00|2007-08-28|20 +|Buchanan|John||2025 NW 29th Rd||Boca Raton|FL|334316303|1000.00|2007-08-28|20 +|Buchanan|John||2025 NW 29th Rd||Boca Raton|FL|334316303|1300.00|2007-08-09|20 +|Buchanan|John||2025 NW 29th Rd||Boca Raton|FL|334316303|200.00|2007-08-14|20 +|Buchanan|John||2025 NW 29th Rd||Boca Raton|FL|334316303|500.00|2007-07-25|20 +|Buchanan|John||4635 49th St NW||Washington|DC|200164320|200.09|2007-09-23|20 +|Harrison|Ryan||2247 3rd St||La Verne|CA|917504918|25.00|2007-07-26|20 +|BYNUM|HERBERT||332 SUNNYSIDE ROAD||TAMPA|FL|336177249|-500.00|2008-03-10|22 +|BYINGTON|MARGARET|E.|2633 MIDDLEBORO LANE N.E.||GRAND RAPIDS|MI|495061254|-2300.00|2008-03-03|22 +|BYERS|BOB|A.|13170 TELFAIR AVENUE||SYLMAR|CA|913423573|-2300.00|2008-03-07|22 +|BYERS|AUDREY||2658 LADBROOK WAY||THOUSAND OAKS|CA|913615073|-200.00|2008-03-07|22 +|BUSH|KRYSTIE||P.O. BOX 61046||DENVER|CO|802061046|-2300.00|2008-03-06|22 +|BUSH|ERIC||P.O. BOX 61046||DENVER|CO|802061046|-2300.00|2008-03-06|22 +|BURTON|SUSAN||9338 DEER CREEK DRIVE||TAMPA|FL|336472286|-2300.00|2008-03-05|22 +|BURTON|STEVEN|G.|9938 DEER CREEK DRIVE||TAMPA|FL|33647|-2300.00|2008-03-05|22 +|BURTON|GLENN|M.|4404 CHARLESTON COURT||TAMPA|FL|336092620|-2300.00|2008-03-05|22 +|BURKHARDT|CRAIG|S.|910 15TH STREET N.W.||WASHINGTON|DC|200052503|-500.00|2008-03-07|22 +|BURKHARDT|CRAIG|S.|910 15TH STREET N.W.||WASHINGTON|DC|200052503|-1000.00|2008-03-07|22 +|BURKHARDT|BARBARA||910 15TH STREET N.W.||WASHINGTON|DC|200052503|-500.00|2008-03-07|22 +|BURKE|SUZANNE|M.|3401 EVANSTON||SEATTLE|WA|981038677|-700.00|2008-03-05|22 +|BURKE|GAIL||165 E. 32ND STREET|APARTMENT 9E|NEW YORK|NY|100166014|-2000.00|2008-03-05|22 +|BURKE|DONALD|J.|12 LOMPOC||RANCHO SANTA MARGA|CA|926881817|-2300.00|2008-03-11|22 +|BURGERT|RONALD|L.|5723 PLUMTREE DRIVE||DALLAS|TX|752524926|-1000.00|2008-03-05|22 +|BULL|BARTLE|B.|439 E. 51ST STREET||NEW YORK|NY|100226473|-800.00|2008-03-10|22 +|BULL|BARTLE|B.|439 E. 51ST STREET||NEW YORK|NY|100226473|-1000.00|2008-03-10|22 +|BUKOWSKI|DANIEL|J.|702 S. WRIGHT STREET||NAPERVILLE|IL|605406736|-100.00|2008-03-10|22 +|BUISSON|MARGARET|A.|P.O. BOX 197029||LOUISVILLE|KY|402597029|-200.00|2008-03-11|22 +|BUCKLEY|WALTER|W.|1635 COUNTRY ROAD||BETHLEHEM|PA|180155718|-100.00|2008-03-05|22 +|BUCKLEY|MARJORIE|B.|1635 COUNTRY ROAD||BETHLEHEM|PA|180155718|-100.00|2008-03-05|22 +|BRUNO|JOHN||10136 WINDERMERE CHASE BLVD.||GOTHA|FL|347344707|-2300.00|2008-03-06|22 +|BRUNO|IRENE||10136 WINDERMERE CHASE BLVD.||GOTHA|FL|347344707|-2300.00|2008-03-06|22 +|BROWN|TIMOTHY|J.|26826 MARLOWE COURT||STEVENSON RANCH|CA|913811020|-2300.00|2008-03-06|22 +|Schuff|Bryan||1700 W Sweden Rd||Brockport|NY|14420|-25.00|2008-08-22|32 +|Hobbs|James||229 Cherry Lane||White House|TN|37188|-25.00|2008-08-19|32 +|Ranganath|Anoop||2507 Willard Drive||Charlottesville|VA|22903|-100.00|2008-04-21|32 +|Nystrom|Michael|A|93A Fairmont Street||Arlington|MA|02474|-503.00|2008-04-21|32 +|Muse|Nina|Jo|2915 Toro Canyon Rd||Austin|TX|78746|-50.00|2008-04-21|32 +|Waddell|James|L.|1823 Spel Lane SW||Rochester|MN|55902|-28.00|2008-04-21|32 +|Brucks|William|C.|PO Box 391||Corona del Mar|CA|92625|-150.00|2008-04-21|32 +|Kuehn|David||14502 West 93rd Street||Lenexa|KS|66215|-330.00|2008-04-21|32 +|Verster|Jeanette|M.|7220 SW 61st St||Miami|FL|331431807|-1000.00|2008-04-21|32 +|Uihlein|Richard||1396 N Waukegan Rd||Lake Forest|IL|600451147|-2300.00|2008-04-21|32 +|Eskenberry|Robert|P|10960 Gray Cir||Westminster|CO|80020|-223.00|2008-04-21|32 +|Froehling|Alan|L.|302 Broadway St||Mount Vernon|IL|628645116|-844.80|2008-04-21|32 +|Duryea|Marcia|A.|123 Bayview Ave||Amityville|NY|11701|-299.50|2008-04-21|32 +|Perreault|Louise||503 Brockridge Hunt Drive||Hampton|VA|23666|-34.08|2008-04-21|32 +|Rozenfeld|Timur||57 Herbert Road||Robbinsville|NJ|08691|-777.95|2008-04-21|32 +|Kazor|Christopher|M|707 Spindletree ave||Naperville|IL|60565|-2592.00|2008-04-21|32 +|Lehner|Thomas|S.|2701 Star Lane||Wadsworth|OH|44281|-200.00|2008-04-21|32 +|Plummer|Joseph||587 Blake Hill Rd||New Hampton|NH|032564424|-24.60|2008-04-21|32 +|Raught|Philip|M|4714 Plum Way||Pittsburgh|PA|15201|-1046.00|2008-04-21|32 +|Ferrara|Judith|D|1508 Waterford Road||Yardley|PA|19067|-1100.00|2008-04-21|32 +|Johnson|Cathleen|E.|1003 Justin Ln Apt 2016||Austin|TX|787572648|-14.76|2008-04-21|32 +|Sanford|Bradley||940 Post St #43||San Francisco|CA|94109|-24.53|2008-04-21|32 +|Gaarder|Bruce||PO Box 4085||Mountain Home AFB|ID|83648|-261.00|2008-04-21|32 +|Choe|Hyeokchan||207 Bridle Way||Fort Lee|NJ|070246302|-39.50|2008-04-21|32 +|Jacobs|Richard|G.|14337 Tawya Rd||Apple Valley|CA|923075545|-1000.00|2008-04-21|32 +|Aaronson|Rebecca||2000 Village Green Dr Apt 12||Mill Creek|WA|980125787|100.00|2008-02-08|34 +|Aarons|Elaine||481 Buck Island Rd Apt 17A|APT 17A|West Yarmouth|MA|026733300|25.00|2008-02-26|34 +|Aarons|Elaine||481 Buck Island Rd Apt 17A|APT 17A|West Yarmouth|MA|026733300|70.00|2008-02-25|34 +|Aarons|Elaine||481 Buck Island Rd Apt 17A|APT 17A|West Yarmouth|MA|026733300|100.00|2008-02-08|34 +|Aaron|Shirley||101 Cherry Ave||Havana|FL|323331311|50.00|2008-02-29|34 +|Aaron|Shirley||101 Cherry Ave||Havana|FL|323331311|100.00|2008-02-29|34 +|Aaronson|Rebecca||2000 Village Green Dr Apt 12||Mill Creek|WA|980125787|100.00|2008-02-14|34 +|Aaron|Shirley||101 Cherry Ave||Havana|FL|323331311|100.00|2008-02-24|34 +|Aaron|Shirley||101 Cherry Ave||Havana|FL|323331311|100.00|2008-02-22|34 +|Aaron|Shirley||101 Cherry Ave||Havana|FL|323331311|100.00|2008-02-17|34 +|Reid|Elizabeth||73 W Patent Rd|OPHIR FARM NORTH|Bedford Hills|NY|105072222|-350.00|2008-08-28|34 +|Reich|Thomas||499 Park Ave||New York|NY|100221240|-2300.00|2008-08-28|34 +|Aaron|Shirley||101 Cherry Ave||Havana|FL|323331311|100.00|2008-02-08|34 +|Aaron|Shirley||101 Cherry Ave||Havana|FL|323331311|100.00|2008-02-03|34 +|Aaron|Sharron||1804 E Montgomery St||Broken Arrow|OK|740121840|500.00|2008-02-09|34 +|Aaron|Patricia||418 NW 35th St||Oklahoma City|OK|731188602|200.00|2008-02-26|34 +|Aaron|Patricia||418 NW 35th St||Oklahoma City|OK|731188602|100.00|2008-02-12|34 +|Aaron|Jim||2178 Fairway Cir||Canton|MI|481885097|300.00|2008-02-07|34 +|Aaron|Jim||2178 Fairway Cir||Canton|MI|481885097|200.00|2008-02-29|34 +|Aaron|Carole||PO Box 1806||Ogunquit|ME|039071806|70.00|2008-02-29|34 +|Aaron|Carole||PO Box 1806||Ogunquit|ME|039071806|50.00|2008-02-07|34 +|Aaron|Carole||PO Box 1806||Ogunquit|ME|039071806|100.00|2008-02-03|34 +|Aaron|Barbara||2298 Pacific Ave # 6||San Francisco|CA|941151435|1000.00|2008-02-11|34 +|Aanonsen|Lin||897 Raymond Ave||Saint Paul|MN|551141508|250.00|2008-02-21|34 +|Aanonsen|Lin||897 Raymond Ave||Saint Paul|MN|551141508|100.00|2008-02-08|34 +|BOURNE|TRAVIS||LAGE KAART 77||BRASSCHATT||02930|-500.00|2008-11-20|35 +|SECRIST|BRIAN|L.|3 MULE DEER TRAIL||LITTLETON|CO|801275722|-1000.00|2008-04-07|35 +|TOLLESTRUP|TRAVIS|W.|16331 WINECREEK RD.||SAN DIEGO|CA|92127|-1000.00|2008-05-15|35 +|ACCORD|DEAN|C.|8813 ROBINSON RIDGE ROAD||LAS VEGAS|NV|891175812|500.00|2007-07-13|35 +|ABTS|HENRY||P. O. BOX 7299||INCLINE VILLAGE|NV|894527299|100.00|2007-07-13|35 +|ABSHIER|LANNY||14191 S.E. HIGHWAY 301||SUMMERFIELD|FL|34491|500.00|2007-09-25|35 +|ABSHIER|DIANA||14191 S.E. HIGHWAY 301||SUMMERFIELD|FL|34491|500.00|2007-09-25|35 +|ABREU|KEVIN|M.|1305 GARDEN GLEN LANE||PEARLAND|TX|775816547|50.00|2007-09-30|35 +|ABREU|KEVIN|M.|1305 GARDEN GLEN LANE||PEARLAND|TX|775816547|150.00|2007-08-09|35 +|ABREU|KEVIN|M.|1305 GARDEN GLEN LANE||PEARLAND|TX|775816547|50.00|2007-07-19|35 +|ABRAMOWITZ|NIRA||411 HARBOR ROAD||SOUTHPORT|CT|068901376|2300.00|2007-09-14|35 +|ABRAMS|MICHAEL||7910 WOODMONT AVENUE||BETHESDA|MD|208143002|250.00|2007-09-29|35 +|ABRAMOWITZ|KEN||200 CENTRAL PARK S.|APARTMENT 31A|NEW YORK|NY|100191448|300.00|2007-09-11|35 +|ABOUBAKARE|NASAR||1400 SAN MIGUEL DRIVE||CORONA DEL MAR|CA|926251300|1000.00|2007-07-09|35 +|ABEGG|PATRICIA|T.|1862 E. 5150 S.||SALT LAKE CITY|UT|841176911|75.00|2007-09-25|35 +|ABEGG|PATRICIA|T.|1862 E. 5150 S.||SALT LAKE CITY|UT|841176911|25.00|2007-09-17|35 +|ABEGG|PATRICIA|T.|1862 E. 5150 S.||SALT LAKE CITY|UT|841176911|75.00|2007-08-31|35 +|ABEGG|PATRICIA|T.|1862 E. 5150 S.||SALT LAKE CITY|UT|841176911|75.00|2007-08-14|35 +|ABEGG|PATRICIA|T.|1862 E. 5150 S.||SALT LAKE CITY|UT|841176911|25.00|2007-08-06|35 +|ABEGG|PATRICIA|T.|1862 E. 5150 S.||SALT LAKE CITY|UT|841176911|25.00|2007-07-10|35 +|ABDELLA|THOMAS|M.|4231 MONUMENT WALL WAY #340||FAIRFAX|VA|220308440|50.00|2007-09-30|35 +|ABBOTT|WELDON|S.|777 EAST SOUTH TEMPLE 4E||SALT LAKE CITY|UT|841021269|100.00|2007-09-29|35 +|ABBOTT|WELDON|S.|777 EAST SOUTH TEMPLE 4E||SALT LAKE CITY|UT|841021269|50.00|2007-08-09|35 +|ABBOTT|GERALD|F.|389 BENEFIT STREET||PROVIDENCE|RI|029032946|100.00|2007-09-15|35 +|ABBOTT|GERALD|F.|389 BENEFIT STREET||PROVIDENCE|RI|029032946|100.00|2007-08-15|35 +|ABEDIN|ZAINUL||715 N. CENTRAL AVENUE|SUITE 212|GLENDALE|CA|912031164|500.00|2008-01-21|37 +|ABBOTT|SYBIL|F.|446 GAMES DRIVE||RENO|NV|895093326|75.00|2008-01-08|37 +|ABBOTT|SYBIL|F.|446 GAMES DRIVE||RENO|NV|895093326|50.00|2008-01-08|37 +|ABBOTT|RONALD|LEANDER|5453 HAWTHORNE STREET||MONTCLAIR|CA|917632551|200.00|2008-01-31|37 +|ABBOTT|RONALD|LEANDER|5453 HAWTHORNE STREET||MONTCLAIR|CA|917632551|100.00|2008-01-08|37 +|ABBOTT|ROBERT|A.|3061 LOREE ROAD||DECKERVILLE|MI|484279763|500.00|2008-01-21|37 +|ABBOTT|MIKE|E.|4516 OSPREY LNDG||NICEVILLE|FL|325786810|1000.00|2008-01-15|37 +|ABBOT|DAVID|M.|56 SALEM STREET||ANDOVER|MA|018102114|200.00|2008-01-21|37 +|ABBO|PAULINE|MORENCY|10720 JACOB LANE||WHITE LAKE|MI|483862274|35.00|2008-01-07|37 +|ABATE|MARIA|ELENA|1291 NIGHTINGALE AVENUE||MIAMI SPRINGS|FL|331663832|2600.00|2008-01-25|37 +|ABAIR|PETER||40 EVANS STREET||WATERTOWN|MA|024722150|25.00|2008-01-09|37 +|ABACHERLI|SHIRLEY|M.|29875 NEWPORT ROAD||MENIFEE|CA|925849524|150.00|2008-01-28|37 +|AARONS|CHARLES||1730 SHORE DRIVE||ANCHORAGE|AK|995153207|300.00|2008-01-30|37 +|AARONS|CHARLES||1730 SHORE DRIVE||ANCHORAGE|AK|995153207|410.00|2008-01-15|37 +|AARONS|CHARLES||1730 SHORE DRIVE||ANCHORAGE|AK|995153207|500.00|2008-01-09|37 +|ABEL|JOHN|H.|422 THOMAS STREET||BETHLEHEM|PA|180153316|200.00|2008-01-22|37 +|ABEL|MARLING|L.|14 HANGING MOSS LANE||GREENVILLE|SC|296155069|100.00|2008-01-22|37 +|ABEL|RUDOLPH||4532 OCEAN BLVD.|# 108|SARASOTA|FL|342421337|100.00|2008-01-08|37 +|ABELE|RODNEY||3620 METAIRIE HEIGHTS AVENUE||METAIRIE|LA|700021823|500.00|2008-01-15|37 +|ABERCROMBIE|DENIS||11811 WATER OAK CT||MAGNOLIA|TX|773546270|500.00|2008-01-30|37 +|ABESHAUS|MERRILL|M.|1801 N. HEREFORD DRIVE||FLAGSTAFF|AZ|860011121|120.00|2008-01-16|37 +|ABRAHAM|GEORGE||P.O. BOX 1504||LAKE CHARLES|LA|706021504|800.00|2008-01-17|37 +|ABRAHAMSON|PETER|J.|1030 W. ROSCOE STREET||CHICAGO|IL|606572207|50.00|2008-01-25|37 +|ABRAHAM|SALEM|A.|P.O. BOX 7||CANADIAN|TX|790140007|1000.00|2008-01-17|37 +|ABRAHAM|SALEM|A.|P.O. BOX 7||CANADIAN|TX|790140007|1300.00|2008-01-30|37