Queer European MD passionate about IT
Bladeren bron

Merge pull request #17 from dataquestio/feature/vik/intermediate-project

Mission 218
Vik Paruchuri 8 jaren geleden
bovenliggende
commit
6eb519a80d
3 gewijzigde bestanden met toevoegingen van 1487 en 1 verwijderingen
  1. 496 0
      Mission218Solutions.ipynb
  2. 989 0
      Mission219Solution.ipynb
  3. 2 1
      README.md

+ 496 - 0
Mission218Solutions.ipynb

@@ -0,0 +1,496 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# US Gun Deaths Guided Project Solutions"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Introducing US Gun Deaths Data"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 30,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "import csv\n",
+    "\n",
+    "with open(\"guns.csv\", \"r\") as f:\n",
+    "    reader = csv.reader(f)\n",
+    "    data = list(reader)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 31,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "[['', 'year', 'month', 'intent', 'police', 'sex', 'age', 'race', 'hispanic', 'place', 'education'], ['1', '2012', '01', 'Suicide', '0', 'M', '34', 'Asian/Pacific Islander', '100', 'Home', '4'], ['2', '2012', '01', 'Suicide', '0', 'F', '21', 'White', '100', 'Street', '3'], ['3', '2012', '01', 'Suicide', '0', 'M', '60', 'White', '100', 'Other specified', '4'], ['4', '2012', '02', 'Suicide', '0', 'M', '64', 'White', '100', 'Home', '4']]\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(data[:5])"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Removing Headers From A List Of Lists"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 32,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "[['', 'year', 'month', 'intent', 'police', 'sex', 'age', 'race', 'hispanic', 'place', 'education']]\n",
+      "[['1', '2012', '01', 'Suicide', '0', 'M', '34', 'Asian/Pacific Islander', '100', 'Home', '4'], ['2', '2012', '01', 'Suicide', '0', 'F', '21', 'White', '100', 'Street', '3'], ['3', '2012', '01', 'Suicide', '0', 'M', '60', 'White', '100', 'Other specified', '4'], ['4', '2012', '02', 'Suicide', '0', 'M', '64', 'White', '100', 'Home', '4'], ['5', '2012', '02', 'Suicide', '0', 'M', '31', 'White', '100', 'Other specified', '2']]\n"
+     ]
+    }
+   ],
+   "source": [
+    "headers = data[:1]\n",
+    "data = data[1:]\n",
+    "print(headers)\n",
+    "print(data[:5])"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Counting Gun Deaths By Year"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 33,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{'2012': 33563, '2013': 33636, '2014': 33599}"
+      ]
+     },
+     "execution_count": 33,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "years = [row[1] for row in data]\n",
+    "\n",
+    "year_counts = {}\n",
+    "for year in years:\n",
+    "    if year not in year_counts:\n",
+    "        year_counts[year] = 0\n",
+    "    year_counts[year] += 1\n",
+    "\n",
+    "year_counts   "
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Exploring Gun Deaths By Month And Year"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 34,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[datetime.datetime(2012, 1, 1, 0, 0),\n",
+       " datetime.datetime(2012, 1, 1, 0, 0),\n",
+       " datetime.datetime(2012, 1, 1, 0, 0),\n",
+       " datetime.datetime(2012, 2, 1, 0, 0),\n",
+       " datetime.datetime(2012, 2, 1, 0, 0)]"
+      ]
+     },
+     "execution_count": 34,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "import datetime\n",
+    "\n",
+    "dates = [datetime.datetime(year=int(row[1]), month=int(row[2]), day=1) for row in data]\n",
+    "dates[:5]"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 35,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{datetime.datetime(2012, 1, 1, 0, 0): 2758,\n",
+       " datetime.datetime(2012, 2, 1, 0, 0): 2357,\n",
+       " datetime.datetime(2012, 3, 1, 0, 0): 2743,\n",
+       " datetime.datetime(2012, 4, 1, 0, 0): 2795,\n",
+       " datetime.datetime(2012, 5, 1, 0, 0): 2999,\n",
+       " datetime.datetime(2012, 6, 1, 0, 0): 2826,\n",
+       " datetime.datetime(2012, 7, 1, 0, 0): 3026,\n",
+       " datetime.datetime(2012, 8, 1, 0, 0): 2954,\n",
+       " datetime.datetime(2012, 9, 1, 0, 0): 2852,\n",
+       " datetime.datetime(2012, 10, 1, 0, 0): 2733,\n",
+       " datetime.datetime(2012, 11, 1, 0, 0): 2729,\n",
+       " datetime.datetime(2012, 12, 1, 0, 0): 2791,\n",
+       " datetime.datetime(2013, 1, 1, 0, 0): 2864,\n",
+       " datetime.datetime(2013, 2, 1, 0, 0): 2375,\n",
+       " datetime.datetime(2013, 3, 1, 0, 0): 2862,\n",
+       " datetime.datetime(2013, 4, 1, 0, 0): 2798,\n",
+       " datetime.datetime(2013, 5, 1, 0, 0): 2806,\n",
+       " datetime.datetime(2013, 6, 1, 0, 0): 2920,\n",
+       " datetime.datetime(2013, 7, 1, 0, 0): 3079,\n",
+       " datetime.datetime(2013, 8, 1, 0, 0): 2859,\n",
+       " datetime.datetime(2013, 9, 1, 0, 0): 2742,\n",
+       " datetime.datetime(2013, 10, 1, 0, 0): 2808,\n",
+       " datetime.datetime(2013, 11, 1, 0, 0): 2758,\n",
+       " datetime.datetime(2013, 12, 1, 0, 0): 2765,\n",
+       " datetime.datetime(2014, 1, 1, 0, 0): 2651,\n",
+       " datetime.datetime(2014, 2, 1, 0, 0): 2361,\n",
+       " datetime.datetime(2014, 3, 1, 0, 0): 2684,\n",
+       " datetime.datetime(2014, 4, 1, 0, 0): 2862,\n",
+       " datetime.datetime(2014, 5, 1, 0, 0): 2864,\n",
+       " datetime.datetime(2014, 6, 1, 0, 0): 2931,\n",
+       " datetime.datetime(2014, 7, 1, 0, 0): 2884,\n",
+       " datetime.datetime(2014, 8, 1, 0, 0): 2970,\n",
+       " datetime.datetime(2014, 9, 1, 0, 0): 2914,\n",
+       " datetime.datetime(2014, 10, 1, 0, 0): 2865,\n",
+       " datetime.datetime(2014, 11, 1, 0, 0): 2756,\n",
+       " datetime.datetime(2014, 12, 1, 0, 0): 2857}"
+      ]
+     },
+     "execution_count": 35,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "date_counts = {}\n",
+    "\n",
+    "for date in dates:\n",
+    "    if date not in date_counts:\n",
+    "        date_counts[date] = 0\n",
+    "    date_counts[date] += 1\n",
+    "\n",
+    "date_counts"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Exploring Gun Deaths By Race And Sex"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 54,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{'F': 14449, 'M': 86349}"
+      ]
+     },
+     "execution_count": 54,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "sexes = [row[5] for row in data]\n",
+    "sex_counts = {}\n",
+    "for sex in sexes:\n",
+    "    if sex not in sex_counts:\n",
+    "        sex_counts[sex] = 0\n",
+    "    sex_counts[sex] += 1\n",
+    "sex_counts"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 36,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{'Asian/Pacific Islander': 1326,\n",
+       " 'Black': 23296,\n",
+       " 'Hispanic': 9022,\n",
+       " 'Native American/Native Alaskan': 917,\n",
+       " 'White': 66237}"
+      ]
+     },
+     "execution_count": 36,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "races = [row[7] for row in data]\n",
+    "race_counts = {}\n",
+    "for race in races:\n",
+    "    if race not in race_counts:\n",
+    "        race_counts[race] = 0\n",
+    "    race_counts[race] += 1\n",
+    "race_counts"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Findings so far\n",
+    "\n",
+    "Gun deaths in the US seem to disproportionately affect men vs women.  They also seem to disproportionately affect minorities, although having some data on the percentage of each race in the overall US population would help.\n",
+    "\n",
+    "There appears to be a minor seasonal correlation, with gun deaths peaking in the summer and declining in the winter.  It might be useful to filter by intent, to see if different categories of intent have different correlations with season, race, or gender."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Reading In A Second Dataset"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 57,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[['Id',\n",
+       "  'Year',\n",
+       "  'Id',\n",
+       "  'Sex',\n",
+       "  'Id',\n",
+       "  'Hispanic Origin',\n",
+       "  'Id',\n",
+       "  'Id2',\n",
+       "  'Geography',\n",
+       "  'Total',\n",
+       "  'Race Alone - White',\n",
+       "  'Race Alone - Hispanic',\n",
+       "  'Race Alone - Black or African American',\n",
+       "  'Race Alone - American Indian and Alaska Native',\n",
+       "  'Race Alone - Asian',\n",
+       "  'Race Alone - Native Hawaiian and Other Pacific Islander',\n",
+       "  'Two or More Races'],\n",
+       " ['cen42010',\n",
+       "  'April 1, 2010 Census',\n",
+       "  'totsex',\n",
+       "  'Both Sexes',\n",
+       "  'tothisp',\n",
+       "  'Total',\n",
+       "  '0100000US',\n",
+       "  '',\n",
+       "  'United States',\n",
+       "  '308745538',\n",
+       "  '197318956',\n",
+       "  '44618105',\n",
+       "  '40250635',\n",
+       "  '3739506',\n",
+       "  '15159516',\n",
+       "  '674625',\n",
+       "  '6984195']]"
+      ]
+     },
+     "execution_count": 57,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "import csv\n",
+    "\n",
+    "with open(\"census.csv\", \"r\") as f:\n",
+    "    reader = csv.reader(f)\n",
+    "    census = list(reader)\n",
+    "    \n",
+    "census"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Computing Rates Of Gun Deaths Per Race"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 40,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{'Asian/Pacific Islander': 8.374309664161762,\n",
+       " 'Black': 57.8773477735196,\n",
+       " 'Hispanic': 20.220491210910907,\n",
+       " 'Native American/Native Alaskan': 24.521955573811088,\n",
+       " 'White': 33.56849303419181}"
+      ]
+     },
+     "execution_count": 40,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "mapping = {\n",
+    "    \"Asian/Pacific Islander\": 15159516 + 674625,\n",
+    "    \"Native American/Native Alaskan\": 3739506,\n",
+    "    \"Black\": 40250635,\n",
+    "    \"Hispanic\": 44618105,\n",
+    "    \"White\": 197318956\n",
+    "}\n",
+    "\n",
+    "race_per_hundredk = {}\n",
+    "for k,v in race_counts.items():\n",
+    "    race_per_hundredk[k] = (v / mapping[k]) * 100000\n",
+    "\n",
+    "race_per_hundredk"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Filtering By Intent"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 41,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{'Asian/Pacific Islander': 3.530346230970155,\n",
+       " 'Black': 48.471284987180944,\n",
+       " 'Hispanic': 12.627161104219914,\n",
+       " 'Native American/Native Alaskan': 8.717729026240365,\n",
+       " 'White': 4.6356417981453335}"
+      ]
+     },
+     "execution_count": 41,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "intents = [row[3] for row in data]\n",
+    "homicide_race_counts = {}\n",
+    "for i,race in enumerate(races):\n",
+    "    if race not in homicide_race_counts:\n",
+    "        homicide_race_counts[race] = 0\n",
+    "    if intents[i] == \"Homicide\":\n",
+    "        homicide_race_counts[race] += 1\n",
+    "\n",
+    "race_per_hundredk = {}\n",
+    "for k,v in homicide_race_counts.items():\n",
+    "    race_per_hundredk[k] = (v / mapping[k]) * 100000\n",
+    "\n",
+    "race_per_hundredk     "
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Findings\n",
+    "\n",
+    "It appears that gun related homicides in the US disproportionately affect people in the `Black` and `Hispanic` racial categories.\n",
+    "\n",
+    "Some areas to investigate further:\n",
+    "\n",
+    "* The link between month and homicide rate.\n",
+    "* Homicide rate by gender.\n",
+    "* The rates of other intents by gender and race.\n",
+    "* Gun death rates by location and education."
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 2",
+   "language": "python",
+   "name": "python2"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 2
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython2",
+   "version": "2.7.9"
+  },
+  "widgets": {
+   "state": {},
+   "version": "1.1.1"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}

+ 989 - 0
Mission219Solution.ipynb

@@ -0,0 +1,989 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Introducing Thanksgiving Dinner Data"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 39,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/html": [
+       "<div>\n",
+       "<table border=\"1\" class=\"dataframe\">\n",
+       "  <thead>\n",
+       "    <tr style=\"text-align: right;\">\n",
+       "      <th></th>\n",
+       "      <th>RespondentID</th>\n",
+       "      <th>Do you celebrate Thanksgiving?</th>\n",
+       "      <th>What is typically the main dish at your Thanksgiving dinner?</th>\n",
+       "      <th>What is typically the main dish at your Thanksgiving dinner? - Other (please specify)</th>\n",
+       "      <th>How is the main dish typically cooked?</th>\n",
+       "      <th>How is the main dish typically cooked? - Other (please specify)</th>\n",
+       "      <th>What kind of stuffing/dressing do you typically have?</th>\n",
+       "      <th>What kind of stuffing/dressing do you typically have? - Other (please specify)</th>\n",
+       "      <th>What type of cranberry saucedo you typically have?</th>\n",
+       "      <th>What type of cranberry saucedo you typically have? - Other (please specify)</th>\n",
+       "      <th>...</th>\n",
+       "      <th>Have you ever tried to meet up with hometown friends on Thanksgiving night?</th>\n",
+       "      <th>Have you ever attended a \"Friendsgiving?\"</th>\n",
+       "      <th>Will you shop any Black Friday sales on Thanksgiving Day?</th>\n",
+       "      <th>Do you work in retail?</th>\n",
+       "      <th>Will you employer make you work on Black Friday?</th>\n",
+       "      <th>How would you describe where you live?</th>\n",
+       "      <th>Age</th>\n",
+       "      <th>What is your gender?</th>\n",
+       "      <th>How much total combined money did all members of your HOUSEHOLD earn last year?</th>\n",
+       "      <th>US Region</th>\n",
+       "    </tr>\n",
+       "  </thead>\n",
+       "  <tbody>\n",
+       "    <tr>\n",
+       "      <th>0</th>\n",
+       "      <td>4337954960</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>Turkey</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Baked</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Bread-based</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>None</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>...</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>No</td>\n",
+       "      <td>No</td>\n",
+       "      <td>No</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Suburban</td>\n",
+       "      <td>18 - 29</td>\n",
+       "      <td>Male</td>\n",
+       "      <td>$75,000 to $99,999</td>\n",
+       "      <td>Middle Atlantic</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>1</th>\n",
+       "      <td>4337951949</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>Turkey</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Baked</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Bread-based</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Other (please specify)</td>\n",
+       "      <td>Homemade cranberry gelatin ring</td>\n",
+       "      <td>...</td>\n",
+       "      <td>No</td>\n",
+       "      <td>No</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>No</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Rural</td>\n",
+       "      <td>18 - 29</td>\n",
+       "      <td>Female</td>\n",
+       "      <td>$50,000 to $74,999</td>\n",
+       "      <td>East South Central</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>2</th>\n",
+       "      <td>4337935621</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>Turkey</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Roasted</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Rice-based</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Homemade</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>...</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>No</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Suburban</td>\n",
+       "      <td>18 - 29</td>\n",
+       "      <td>Male</td>\n",
+       "      <td>$0 to $9,999</td>\n",
+       "      <td>Mountain</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>3</th>\n",
+       "      <td>4337933040</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>Turkey</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Baked</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Bread-based</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Homemade</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>...</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>No</td>\n",
+       "      <td>No</td>\n",
+       "      <td>No</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Urban</td>\n",
+       "      <td>30 - 44</td>\n",
+       "      <td>Male</td>\n",
+       "      <td>$200,000 and up</td>\n",
+       "      <td>Pacific</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>4</th>\n",
+       "      <td>4337931983</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>Tofurkey</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Baked</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Bread-based</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Canned</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>...</td>\n",
+       "      <td>Yes</td>\n",
+       "      <td>No</td>\n",
+       "      <td>No</td>\n",
+       "      <td>No</td>\n",
+       "      <td>NaN</td>\n",
+       "      <td>Urban</td>\n",
+       "      <td>30 - 44</td>\n",
+       "      <td>Male</td>\n",
+       "      <td>$100,000 to $124,999</td>\n",
+       "      <td>Pacific</td>\n",
+       "    </tr>\n",
+       "  </tbody>\n",
+       "</table>\n",
+       "<p>5 rows × 65 columns</p>\n",
+       "</div>"
+      ],
+      "text/plain": [
+       "   RespondentID Do you celebrate Thanksgiving?  \\\n",
+       "0    4337954960                            Yes   \n",
+       "1    4337951949                            Yes   \n",
+       "2    4337935621                            Yes   \n",
+       "3    4337933040                            Yes   \n",
+       "4    4337931983                            Yes   \n",
+       "\n",
+       "  What is typically the main dish at your Thanksgiving dinner?  \\\n",
+       "0                                             Turkey             \n",
+       "1                                             Turkey             \n",
+       "2                                             Turkey             \n",
+       "3                                             Turkey             \n",
+       "4                                           Tofurkey             \n",
+       "\n",
+       "  What is typically the main dish at your Thanksgiving dinner? - Other (please specify)  \\\n",
+       "0                                                NaN                                      \n",
+       "1                                                NaN                                      \n",
+       "2                                                NaN                                      \n",
+       "3                                                NaN                                      \n",
+       "4                                                NaN                                      \n",
+       "\n",
+       "  How is the main dish typically cooked?  \\\n",
+       "0                                  Baked   \n",
+       "1                                  Baked   \n",
+       "2                                Roasted   \n",
+       "3                                  Baked   \n",
+       "4                                  Baked   \n",
+       "\n",
+       "  How is the main dish typically cooked? - Other (please specify)  \\\n",
+       "0                                                NaN                \n",
+       "1                                                NaN                \n",
+       "2                                                NaN                \n",
+       "3                                                NaN                \n",
+       "4                                                NaN                \n",
+       "\n",
+       "  What kind of stuffing/dressing do you typically have?  \\\n",
+       "0                                        Bread-based      \n",
+       "1                                        Bread-based      \n",
+       "2                                         Rice-based      \n",
+       "3                                        Bread-based      \n",
+       "4                                        Bread-based      \n",
+       "\n",
+       "  What kind of stuffing/dressing do you typically have? - Other (please specify)  \\\n",
+       "0                                                NaN                               \n",
+       "1                                                NaN                               \n",
+       "2                                                NaN                               \n",
+       "3                                                NaN                               \n",
+       "4                                                NaN                               \n",
+       "\n",
+       "  What type of cranberry saucedo you typically have?  \\\n",
+       "0                                               None   \n",
+       "1                             Other (please specify)   \n",
+       "2                                           Homemade   \n",
+       "3                                           Homemade   \n",
+       "4                                             Canned   \n",
+       "\n",
+       "  What type of cranberry saucedo you typically have? - Other (please specify)  \\\n",
+       "0                                                NaN                            \n",
+       "1                    Homemade cranberry gelatin ring                            \n",
+       "2                                                NaN                            \n",
+       "3                                                NaN                            \n",
+       "4                                                NaN                            \n",
+       "\n",
+       "          ...          \\\n",
+       "0         ...           \n",
+       "1         ...           \n",
+       "2         ...           \n",
+       "3         ...           \n",
+       "4         ...           \n",
+       "\n",
+       "  Have you ever tried to meet up with hometown friends on Thanksgiving night?  \\\n",
+       "0                                                Yes                            \n",
+       "1                                                 No                            \n",
+       "2                                                Yes                            \n",
+       "3                                                Yes                            \n",
+       "4                                                Yes                            \n",
+       "\n",
+       "  Have you ever attended a \"Friendsgiving?\"  \\\n",
+       "0                                        No   \n",
+       "1                                        No   \n",
+       "2                                       Yes   \n",
+       "3                                        No   \n",
+       "4                                        No   \n",
+       "\n",
+       "  Will you shop any Black Friday sales on Thanksgiving Day?  \\\n",
+       "0                                                 No          \n",
+       "1                                                Yes          \n",
+       "2                                                Yes          \n",
+       "3                                                 No          \n",
+       "4                                                 No          \n",
+       "\n",
+       "  Do you work in retail? Will you employer make you work on Black Friday?  \\\n",
+       "0                     No                                              NaN   \n",
+       "1                     No                                              NaN   \n",
+       "2                     No                                              NaN   \n",
+       "3                     No                                              NaN   \n",
+       "4                     No                                              NaN   \n",
+       "\n",
+       "  How would you describe where you live?      Age What is your gender?  \\\n",
+       "0                               Suburban  18 - 29                 Male   \n",
+       "1                                  Rural  18 - 29               Female   \n",
+       "2                               Suburban  18 - 29                 Male   \n",
+       "3                                  Urban  30 - 44                 Male   \n",
+       "4                                  Urban  30 - 44                 Male   \n",
+       "\n",
+       "  How much total combined money did all members of your HOUSEHOLD earn last year?  \\\n",
+       "0                                 $75,000 to $99,999                                \n",
+       "1                                 $50,000 to $74,999                                \n",
+       "2                                       $0 to $9,999                                \n",
+       "3                                    $200,000 and up                                \n",
+       "4                               $100,000 to $124,999                                \n",
+       "\n",
+       "            US Region  \n",
+       "0     Middle Atlantic  \n",
+       "1  East South Central  \n",
+       "2            Mountain  \n",
+       "3             Pacific  \n",
+       "4             Pacific  \n",
+       "\n",
+       "[5 rows x 65 columns]"
+      ]
+     },
+     "execution_count": 39,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "import pandas as pd\n",
+    "\n",
+    "data = pd.read_csv(\"thanksgiving.csv\", encoding=\"Latin-1\")\n",
+    "data.head()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 40,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "Index(['RespondentID', 'Do you celebrate Thanksgiving?',\n",
+       "       'What is typically the main dish at your Thanksgiving dinner?',\n",
+       "       'What is typically the main dish at your Thanksgiving dinner? - Other (please specify)',\n",
+       "       'How is the main dish typically cooked?',\n",
+       "       'How is the main dish typically cooked? - Other (please specify)',\n",
+       "       'What kind of stuffing/dressing do you typically have?',\n",
+       "       'What kind of stuffing/dressing do you typically have? - Other (please specify)',\n",
+       "       'What type of cranberry saucedo you typically have?',\n",
+       "       'What type of cranberry saucedo you typically have? - Other (please specify)',\n",
+       "       'Do you typically have gravy?',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Brussel sprouts',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Carrots',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Cauliflower',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Corn',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Cornbread',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Fruit salad',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Green beans/green bean casserole',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Macaroni and cheese',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Mashed potatoes',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Rolls/biscuits',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Squash',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Vegetable salad',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Yams/sweet potato casserole',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Other (please specify)',\n",
+       "       'Which of these side dishes aretypically served at your Thanksgiving dinner? Please select all that apply. - Other (please specify).1',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Apple',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Buttermilk',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Cherry',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Chocolate',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Coconut cream',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Key lime',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Peach',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Pecan',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Pumpkin',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Sweet Potato',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - None',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Other (please specify)',\n",
+       "       'Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Other (please specify).1',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Apple cobbler',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Blondies',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Brownies',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Carrot cake',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Cheesecake',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Cookies',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Fudge',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Ice cream',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Peach cobbler',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - None',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Other (please specify)',\n",
+       "       'Which of these desserts do you typically have at Thanksgiving dinner? Please select all that apply.   - Other (please specify).1',\n",
+       "       'Do you typically pray before or after the Thanksgiving meal?',\n",
+       "       'How far will you travel for Thanksgiving?',\n",
+       "       'Will you watch any of the following programs on Thanksgiving? Please select all that apply. - Macy's Parade',\n",
+       "       'What's the age cutoff at your \"kids' table\" at Thanksgiving?',\n",
+       "       'Have you ever tried to meet up with hometown friends on Thanksgiving night?',\n",
+       "       'Have you ever attended a \"Friendsgiving?\"',\n",
+       "       'Will you shop any Black Friday sales on Thanksgiving Day?',\n",
+       "       'Do you work in retail?',\n",
+       "       'Will you employer make you work on Black Friday?',\n",
+       "       'How would you describe where you live?', 'Age', 'What is your gender?',\n",
+       "       'How much total combined money did all members of your HOUSEHOLD earn last year?',\n",
+       "       'US Region'],\n",
+       "      dtype='object')"
+      ]
+     },
+     "execution_count": 40,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data.columns"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Filtering Out Rows From A DataFrame"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 41,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "Yes    980\n",
+       "No      78\n",
+       "Name: Do you celebrate Thanksgiving?, dtype: int64"
+      ]
+     },
+     "execution_count": 41,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data[\"Do you celebrate Thanksgiving?\"].value_counts()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 42,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "data = data[data[\"Do you celebrate Thanksgiving?\"] == \"Yes\"]"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Using value_counts To Explore Main Dishes"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 43,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "Turkey                    859\n",
+       "Other (please specify)     35\n",
+       "Ham/Pork                   29\n",
+       "Tofurkey                   20\n",
+       "Chicken                    12\n",
+       "Roast beef                 11\n",
+       "I don't know                5\n",
+       "Turducken                   3\n",
+       "Name: What is typically the main dish at your Thanksgiving dinner?, dtype: int64"
+      ]
+     },
+     "execution_count": 43,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data[\"What is typically the main dish at your Thanksgiving dinner?\"].value_counts()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 44,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "4      Yes\n",
+       "33     Yes\n",
+       "69      No\n",
+       "72      No\n",
+       "77     Yes\n",
+       "145    Yes\n",
+       "175    Yes\n",
+       "218     No\n",
+       "243    Yes\n",
+       "275     No\n",
+       "393    Yes\n",
+       "399    Yes\n",
+       "571    Yes\n",
+       "594    Yes\n",
+       "628     No\n",
+       "774     No\n",
+       "820     No\n",
+       "837    Yes\n",
+       "860     No\n",
+       "953    Yes\n",
+       "Name: Do you typically have gravy?, dtype: object"
+      ]
+     },
+     "execution_count": 44,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data[data[\"What is typically the main dish at your Thanksgiving dinner?\"] == \"Tofurkey\"][\"Do you typically have gravy?\"]"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Figuring Out What Pies People Eat"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 51,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "Apple    514\n",
+       "Name: Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Apple, dtype: int64"
+      ]
+     },
+     "execution_count": 51,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data[\"Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Apple\"].value_counts()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 52,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "False    876\n",
+       "True     104\n",
+       "dtype: int64"
+      ]
+     },
+     "execution_count": 52,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "ate_pies = (pd.isnull(data[\"Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Apple\"])\n",
+    "&\n",
+    "pd.isnull(data[\"Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Pecan\"])\n",
+    " &\n",
+    " pd.isnull(data[\"Which type of pie is typically served at your Thanksgiving dinner? Please select all that apply. - Pumpkin\"])\n",
+    ")\n",
+    "\n",
+    "ate_pies.value_counts()"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Converting Age To Numeric"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 45,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "45 - 59    269\n",
+       "60+        258\n",
+       "30 - 44    235\n",
+       "18 - 29    185\n",
+       "Name: Age, dtype: int64"
+      ]
+     },
+     "execution_count": 45,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data[\"Age\"].value_counts()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 46,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "/Users/vik/python_envs/dscontent/lib/python3.4/site-packages/numpy/lib/function_base.py:3834: RuntimeWarning: Invalid value encountered in percentile\n",
+      "  RuntimeWarning)\n"
+     ]
+    },
+    {
+     "data": {
+      "text/plain": [
+       "count    947.000000\n",
+       "mean      40.089757\n",
+       "std       15.352014\n",
+       "min       18.000000\n",
+       "25%             NaN\n",
+       "50%             NaN\n",
+       "75%             NaN\n",
+       "max       60.000000\n",
+       "Name: int_age, dtype: float64"
+      ]
+     },
+     "execution_count": 46,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "def extract_age(age_str):\n",
+    "    if pd.isnull(age_str):\n",
+    "        return None\n",
+    "    age_str = age_str.split(\" \")[0]\n",
+    "    age_str = age_str.replace(\"+\", \"\")\n",
+    "    return int(age_str)\n",
+    "\n",
+    "data[\"int_age\"] = data[\"Age\"].apply(extract_age)\n",
+    "data[\"int_age\"].describe()"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Findings\n",
+    "\n",
+    "Although we only have a rough approximation of age, and it skews downward because we took the first value in each string (the lower bound), we can see that that age groups of respondents are fairly evenly distributed."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Converting Income To Numeric"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 47,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "$25,000 to $49,999      166\n",
+       "$50,000 to $74,999      127\n",
+       "$75,000 to $99,999      127\n",
+       "Prefer not to answer    118\n",
+       "$100,000 to $124,999    109\n",
+       "$200,000 and up          76\n",
+       "$10,000 to $24,999       60\n",
+       "$0 to $9,999             52\n",
+       "$125,000 to $149,999     48\n",
+       "$150,000 to $174,999     38\n",
+       "$175,000 to $199,999     26\n",
+       "Name: How much total combined money did all members of your HOUSEHOLD earn last year?, dtype: int64"
+      ]
+     },
+     "execution_count": 47,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data[\"How much total combined money did all members of your HOUSEHOLD earn last year?\"].value_counts()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 48,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "/Users/vik/python_envs/dscontent/lib/python3.4/site-packages/numpy/lib/function_base.py:3834: RuntimeWarning: Invalid value encountered in percentile\n",
+      "  RuntimeWarning)\n"
+     ]
+    },
+    {
+     "data": {
+      "text/plain": [
+       "count       829.000000\n",
+       "mean      75965.018094\n",
+       "std       59068.636748\n",
+       "min           0.000000\n",
+       "25%                NaN\n",
+       "50%                NaN\n",
+       "75%                NaN\n",
+       "max      200000.000000\n",
+       "Name: int_income, dtype: float64"
+      ]
+     },
+     "execution_count": 48,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "def extract_income(income_str):\n",
+    "    if pd.isnull(income_str):\n",
+    "        return None\n",
+    "    income_str = income_str.split(\" \")[0]\n",
+    "    if income_str == \"Prefer\":\n",
+    "        return None\n",
+    "    income_str = income_str.replace(\",\", \"\")\n",
+    "    income_str = income_str.replace(\"$\", \"\")\n",
+    "    return int(income_str)\n",
+    "\n",
+    "data[\"int_income\"] = data[\"How much total combined money did all members of your HOUSEHOLD earn last year?\"].apply(extract_income)\n",
+    "data[\"int_income\"].describe()"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Findings\n",
+    "\n",
+    "Although we only have a rough approximation of income, and it skews downward because we took the first value in each string (the lower bound), the average income seems to be fairly high, although there is also a large standard deviation."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Correlating Travel Distance And Income"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 49,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "Thanksgiving is happening at my home--I won't travel at all                         106\n",
+       "Thanksgiving is local--it will take place in the town I live in                      92\n",
+       "Thanksgiving is out of town but not too far--it's a drive of a few hours or less     64\n",
+       "Thanksgiving is out of town and far away--I have to drive several hours or fly       16\n",
+       "Name: How far will you travel for Thanksgiving?, dtype: int64"
+      ]
+     },
+     "execution_count": 49,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data[data[\"int_income\"] < 50000][\"How far will you travel for Thanksgiving?\"].value_counts()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 50,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "Thanksgiving is happening at my home--I won't travel at all                         49\n",
+       "Thanksgiving is local--it will take place in the town I live in                     25\n",
+       "Thanksgiving is out of town but not too far--it's a drive of a few hours or less    16\n",
+       "Thanksgiving is out of town and far away--I have to drive several hours or fly      12\n",
+       "Name: How far will you travel for Thanksgiving?, dtype: int64"
+      ]
+     },
+     "execution_count": 50,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data[data[\"int_income\"] > 150000][\"How far will you travel for Thanksgiving?\"].value_counts()"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Findings\n",
+    "\n",
+    "It appears that more people with high income have Thanksgiving at home than people with low income.  This may be because younger students, who don't have a high income, tend to go home, whereas parents, who have higher incomes, don't."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Linking Friendship And Age"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 53,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/html": [
+       "<div>\n",
+       "<table border=\"1\" class=\"dataframe\">\n",
+       "  <thead>\n",
+       "    <tr style=\"text-align: right;\">\n",
+       "      <th>Have you ever attended a \"Friendsgiving?\"</th>\n",
+       "      <th>No</th>\n",
+       "      <th>Yes</th>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>Have you ever tried to meet up with hometown friends on Thanksgiving night?</th>\n",
+       "      <th></th>\n",
+       "      <th></th>\n",
+       "    </tr>\n",
+       "  </thead>\n",
+       "  <tbody>\n",
+       "    <tr>\n",
+       "      <th>No</th>\n",
+       "      <td>42.283702</td>\n",
+       "      <td>37.010526</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>Yes</th>\n",
+       "      <td>41.475410</td>\n",
+       "      <td>33.976744</td>\n",
+       "    </tr>\n",
+       "  </tbody>\n",
+       "</table>\n",
+       "</div>"
+      ],
+      "text/plain": [
+       "Have you ever attended a \"Friendsgiving?\"                  No        Yes\n",
+       "Have you ever tried to meet up with hometown fr...                      \n",
+       "No                                                  42.283702  37.010526\n",
+       "Yes                                                 41.475410  33.976744"
+      ]
+     },
+     "execution_count": 53,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data.pivot_table(\n",
+    "    index=\"Have you ever tried to meet up with hometown friends on Thanksgiving night?\", \n",
+    "    columns='Have you ever attended a \"Friendsgiving?\"',\n",
+    "    values=\"int_age\"\n",
+    ")"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 54,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/html": [
+       "<div>\n",
+       "<table border=\"1\" class=\"dataframe\">\n",
+       "  <thead>\n",
+       "    <tr style=\"text-align: right;\">\n",
+       "      <th>Have you ever attended a \"Friendsgiving?\"</th>\n",
+       "      <th>No</th>\n",
+       "      <th>Yes</th>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>Have you ever tried to meet up with hometown friends on Thanksgiving night?</th>\n",
+       "      <th></th>\n",
+       "      <th></th>\n",
+       "    </tr>\n",
+       "  </thead>\n",
+       "  <tbody>\n",
+       "    <tr>\n",
+       "      <th>No</th>\n",
+       "      <td>78914.549654</td>\n",
+       "      <td>72894.736842</td>\n",
+       "    </tr>\n",
+       "    <tr>\n",
+       "      <th>Yes</th>\n",
+       "      <td>78750.000000</td>\n",
+       "      <td>66019.736842</td>\n",
+       "    </tr>\n",
+       "  </tbody>\n",
+       "</table>\n",
+       "</div>"
+      ],
+      "text/plain": [
+       "Have you ever attended a \"Friendsgiving?\"                     No           Yes\n",
+       "Have you ever tried to meet up with hometown fr...                            \n",
+       "No                                                  78914.549654  72894.736842\n",
+       "Yes                                                 78750.000000  66019.736842"
+      ]
+     },
+     "execution_count": 54,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "data.pivot_table(\n",
+    "    index=\"Have you ever tried to meet up with hometown friends on Thanksgiving night?\", \n",
+    "    columns='Have you ever attended a \"Friendsgiving?\"',\n",
+    "    values=\"int_income\"\n",
+    ")"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Findings\n",
+    "\n",
+    "It appears that people who are younger are more likely to attend a Friendsgiving, and try to meet up with friends on Thanksgiving."
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 2",
+   "language": "python",
+   "name": "python2"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 2
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython2",
+   "version": "2.7.9"
+  },
+  "widgets": {
+   "state": {},
+   "version": "1.1.1"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}

+ 2 - 1
README.md

@@ -15,4 +15,5 @@ Of course, there are always going to be multiple ways to solve any one problem,
 - [Guided Project: Preparing data for SQLite](https://github.com/dataquestio/solutions/blob/master/Mission215Solutions.ipynb)
 - [Guided Project: Creating relations in SQLite](https://github.com/dataquestio/solutions/blob/master/Mission216Solutions.ipynb)
 - [Guided Project: Analyzing NYC High School Data](https://github.com/dataquestio/solutions/blob/master/Mission217Solutions.ipynb)
-- [Guided Project: Visualizing Earnings Based On College Majors](https://github.com/dataquestio/solutions/blob/master/Mission146Solutions.ipynb)
+- [Guided Project: Visualizing Earnings Based On College Majors](https://github.com/dataquestio/solutions/blob/master/Mission146Solutions.ipynb)
+- [Guided Project: Exploring Gun Deaths in the US](https://github.com/dataquestio/solutions/blob/master/Mission218Solutions.ipynb)