{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "42901bdc-1637-4bad-b7fd-d901aaa7488b",
   "metadata": {},
   "source": [
    "## **OVERARCHING QUESTION:** *DO PEOPLE WHO EXIBIT RISKY BEHAVIORS (SMOKING, GAMBLING, DRINKING) ORDER THEIR STEAK IN THE SAME RISKY MANNER AS THEIR BEAHVIORS (RARE). IS THERE A RELATIONSHIP BETWEEN THE TWO.*\n",
    "![alt text](risk.jpg)\n",
    "\n",
    "**Why this question**\n",
    "\n",
    "THE CENTRAL QUESTION WOULD ASK DO PEOPLE (males and females) WHO HAVE AN AFFINITY FOR RISKY BEHAVIORS, SPECIFICALLY (SMOKING, DRINKING, GAMBLING) ALSO HAVE A RISKY BEHAVIOR WHEN IT COMES TO EATING THEIR FOOD. SPECIFICALLY IN THIS STUDY, IT IS ABOUT ORDERING STEAK.\n",
    "I AM INTERESTED IN THIS QUESTION BECASUE IT IS INTERESTING TO SEE IF FOOD RISK BEHAVIORS ARE ASSOCIATED WITH ACTIVITY RISK BEHAVIORS. I ALSO AM INTERESTED TO SEE IN THIS STUDY HOW INCOME LEVELS EFFECT THESE DECISIONS AS WELL AS EDUCATION LEVELS, WHICH IS ALSO IN THE STUDY.\n",
    "\n",
    "![alt text](r.jpg)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "technical-evans",
   "metadata": {},
   "outputs": [],
   "source": [
    "#Include any import statements you will need\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "sns.set_theme()\n",
    "steak = pd.read_csv(\"steak.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "overhead-sigma",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>smoke</th>\n",
       "      <th>drink</th>\n",
       "      <th>gamble</th>\n",
       "      <th>cooked</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Age</th>\n",
       "      <th>Household Income</th>\n",
       "      <th>Education</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Medium</td>\n",
       "      <td>Male</td>\n",
       "      <td>&gt; 60</td>\n",
       "      <td>$50,000 - $99,999</td>\n",
       "      <td>Bachelor degree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>No</td>\n",
       "      <td>Yes</td>\n",
       "      <td>No</td>\n",
       "      <td>Medium</td>\n",
       "      <td>Male</td>\n",
       "      <td>&gt; 60</td>\n",
       "      <td>$50,000 - $99,999</td>\n",
       "      <td>Graduate degree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Medium</td>\n",
       "      <td>Male</td>\n",
       "      <td>18-29</td>\n",
       "      <td>$50,000 - $99,999</td>\n",
       "      <td>Bachelor degree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>No</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Medium</td>\n",
       "      <td>Male</td>\n",
       "      <td>18-29</td>\n",
       "      <td>$50,000 - $99,999</td>\n",
       "      <td>Bachelor degree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>No</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Medium</td>\n",
       "      <td>Male</td>\n",
       "      <td>18-29</td>\n",
       "      <td>$50,000 - $99,999</td>\n",
       "      <td>Bachelor degree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>427</th>\n",
       "      <td>No</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Well</td>\n",
       "      <td>Female</td>\n",
       "      <td>45-60</td>\n",
       "      <td>$150,000+</td>\n",
       "      <td>High school degree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>428</th>\n",
       "      <td>NaN</td>\n",
       "      <td>No</td>\n",
       "      <td>No</td>\n",
       "      <td>Well</td>\n",
       "      <td>Male</td>\n",
       "      <td>45-60</td>\n",
       "      <td>$50,000 - $99,999</td>\n",
       "      <td>Bachelor degree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>429</th>\n",
       "      <td>No</td>\n",
       "      <td>Yes</td>\n",
       "      <td>No</td>\n",
       "      <td>Well</td>\n",
       "      <td>Male</td>\n",
       "      <td>30-44</td>\n",
       "      <td>$0 - $24,999</td>\n",
       "      <td>Some college or Associate degree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>430</th>\n",
       "      <td>No</td>\n",
       "      <td>No</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Well</td>\n",
       "      <td>Female</td>\n",
       "      <td>30-44</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Some college or Associate degree</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>431</th>\n",
       "      <td>No</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Well</td>\n",
       "      <td>Female</td>\n",
       "      <td>&gt; 60</td>\n",
       "      <td>$100,000 - $149,999</td>\n",
       "      <td>Bachelor degree</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>432 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    smoke drink gamble  cooked  Gender    Age     Household Income  \\\n",
       "0     Yes   Yes    Yes  Medium    Male   > 60    $50,000 - $99,999   \n",
       "1      No   Yes     No  Medium    Male   > 60    $50,000 - $99,999   \n",
       "2     Yes   Yes    Yes  Medium    Male  18-29    $50,000 - $99,999   \n",
       "3      No   Yes    Yes  Medium    Male  18-29    $50,000 - $99,999   \n",
       "4      No   Yes    Yes  Medium    Male  18-29    $50,000 - $99,999   \n",
       "..    ...   ...    ...     ...     ...    ...                  ...   \n",
       "427    No   Yes    Yes    Well  Female  45-60            $150,000+   \n",
       "428   NaN    No     No    Well    Male  45-60    $50,000 - $99,999   \n",
       "429    No   Yes     No    Well    Male  30-44         $0 - $24,999   \n",
       "430    No    No    Yes    Well  Female  30-44                  NaN   \n",
       "431    No   Yes    Yes    Well  Female   > 60  $100,000 - $149,999   \n",
       "\n",
       "                            Education  \n",
       "0                     Bachelor degree  \n",
       "1                     Graduate degree  \n",
       "2                     Bachelor degree  \n",
       "3                     Bachelor degree  \n",
       "4                     Bachelor degree  \n",
       "..                                ...  \n",
       "427                High school degree  \n",
       "428                   Bachelor degree  \n",
       "429  Some college or Associate degree  \n",
       "430  Some college or Associate degree  \n",
       "431                   Bachelor degree  \n",
       "\n",
       "[432 rows x 8 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "steak"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "8d7c325c-ef3f-4072-a51c-1e87325a3c96",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Gender\n",
       "Male      212\n",
       "Female    200\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "steak.Gender.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "2899053c-9446-4772-8cc2-113a238b967a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='Gender', ylabel='Count'>"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 18312 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.histplot(data=steak, x=\"Gender\")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "continental-franklin",
   "metadata": {},
   "source": [
    "**What is the data about and where is it from?**\n",
    "\n",
    "![alt text](538.jpg)\n",
    "\n",
    "This is a data set from the website 538. It was a data set collected by Walt Hickey. It is a steak risky survey. The data examines how people value and interpret risk in life, and does this have a correlation to how they order their steak. 550 people were surveyed. It seeks to interpret if people who do risky behaviors (smoke, gamble, drink) order their steak in the same manner (rare) and risk food borne illness."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "infinite-instrument",
   "metadata": {},
   "source": [
    "# Methods and Results"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "recognized-positive",
   "metadata": {},
   "source": [
    "## First Research Question: *Do people (males and females) who drink also order their steak rare?*\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "graduate-palmer",
   "metadata": {},
   "source": [
    "### Methods"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "endless-variation",
   "metadata": {},
   "source": [
    "*Explain how you will approach this research question below. Consider the following:* \n",
    "  - *Which aspects of the dataset will you use?* \n",
    "  - *How will you reorganize/store the data?* \n",
    "  - *What data science tools/functions will you use and why?*\n",
    "\n",
    "\n",
    "**I will use the columns Drink/Cooked to answer this question.\n",
    "I will...\n",
    "\n",
    "-get the value of people who drink\n",
    "-get the value of people who order steak rare\n",
    "-get the value of people who do both drinking and order their steak rare\n",
    "\n",
    "I will use pandas to handle my data (as data frames), seaborne to create visualizations\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "portuguese-japan",
   "metadata": {},
   "source": [
    "# Results "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68678a65-6dd4-4fff-bb4e-70492249e021",
   "metadata": {},
   "source": [
    "### Number of people who Drink"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "negative-highlight",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "drink\n",
       "Yes    339\n",
       "No      93\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "steak.drink.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "victorian-burning",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='drink', ylabel='Count'>"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 16908 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.histplot(data=steak, x=\"drink\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e0ec8c49-e490-4bac-927a-0f3c50c72c8d",
   "metadata": {},
   "source": [
    "### Number of people who like their steak rare\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "46f2704d-6336-4b76-a7db-8cde388f7d55",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "cooked\n",
       "Medium rare    166\n",
       "Medium         132\n",
       "Medium Well     75\n",
       "Well            36\n",
       "Rare            23\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "steak.cooked.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "45451f54-ebc8-4acc-aec7-64ecd9842709",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='cooked', ylabel='Count'>"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 21984 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.histplot(data=steak, x=\"cooked\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ec996656-8880-4077-bc4f-01e7d600dece",
   "metadata": {},
   "source": [
    "### Number of people who like their steak rare, and who drink"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "5d1555da-3c4f-4105-b7b7-83a1bfb3f833",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "drink  cooked     \n",
      "No     Medium          23\n",
      "       Medium Well     17\n",
      "       Medium rare     38\n",
      "       Rare             3\n",
      "       Well            12\n",
      "Yes    Medium         109\n",
      "       Medium Well     58\n",
      "       Medium rare    128\n",
      "       Rare            20\n",
      "       Well            24\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "\n",
    "counts = steak.groupby([\"drink\", 'cooked']).size()\n",
    "print(counts)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "32ca9aa2-e1ad-4563-b2de-55326f187e1f",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='drink', ylabel='count'>"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 26960 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.countplot(x='drink', hue='cooked', data=steak)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "a72f700e-4d9b-46d9-a216-69b754fd409f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of people who drink and order their steak rare: 20\n"
     ]
    }
   ],
   "source": [
    "df = steak.dropna(subset=['drink', 'cooked'])\n",
    "drink_rare = df[(df['drink'].str.lower() == 'yes') & (df['cooked'].str.lower() == 'rare')]\n",
    "count_drink_rare = len(drink_rare)\n",
    "print(f\"Number of people who drink and order their steak rare: {count_drink_rare}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "collectible-puppy",
   "metadata": {},
   "source": [
    "## Second Research Question: *Do people (males and females) who gamble also order their steak rare?*\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "demographic-future",
   "metadata": {},
   "source": [
    "### Methods"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "incorporate-roller",
   "metadata": {},
   "source": [
    "*Explain how you will approach this research question below. Consider the following:* \n",
    "  - *Which aspects of the dataset will you use?* \n",
    "  - *How will you reorganize/store the data?* \n",
    "  - *What data science tools/functions will you use and why?* \n",
    "\n",
    "✏️ *Write your answer below:*\n",
    "\n",
    "**I will use the columns Gamble/Cooked to answer this question.\n",
    "I will...\n",
    "\n",
    "-get the value of people who gamble\n",
    "-get the value of people who order steak rare\n",
    "-get the value of people who do both gamble and order their steak rare\n",
    "\n",
    "I will use pandas to handle my data (as data frames), seaborne to create visualizations\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "juvenile-creation",
   "metadata": {},
   "source": [
    "# Results "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8d239cc7-d973-452d-a462-7317ab8fe5f2",
   "metadata": {},
   "source": [
    "### Number of people who gamble\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "pursuant-surrey",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "gamble\n",
       "Yes    216\n",
       "No     213\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "steak.gamble.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "located-night",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='gamble', ylabel='Count'>"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 13828 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.histplot(data=steak, x=\"gamble\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e213a7eb-6a17-4db7-bda6-200200421688",
   "metadata": {},
   "source": [
    "### Number of people who like their steak rare\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "c520afe4-e348-4573-a6f3-9968cc8b594b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "cooked\n",
       "Medium rare    166\n",
       "Medium         132\n",
       "Medium Well     75\n",
       "Well            36\n",
       "Rare            23\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "steak.cooked.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "b7fd5c7a-a8cb-4253-912b-d062f88caf25",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='cooked', ylabel='Count'>"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 21984 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.histplot(data=steak, x=\"cooked\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "996d3496-8057-4c0f-b083-ead62e394fde",
   "metadata": {},
   "source": [
    "### Number of people who like their steak rare, and who gamble"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "f75ee0b2-8ed2-40d2-9a6e-dd839663f364",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gamble  cooked     \n",
      "No      Medium         59\n",
      "        Medium Well    40\n",
      "        Medium rare    85\n",
      "        Rare           11\n",
      "        Well           18\n",
      "Yes     Medium         73\n",
      "        Medium Well    32\n",
      "        Medium rare    81\n",
      "        Rare           12\n",
      "        Well           18\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "counts = df.groupby([\"gamble\", 'cooked']).size()\n",
    "print(counts)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "8082a773-1acd-4da5-beef-e78b82e4bca7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='gamble', ylabel='count'>"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 28928 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.countplot(x='gamble', hue='cooked', data=df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "506a2001-d2dc-4e66-b330-699d5194db2d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of people who gamble and order their steak rare: 12\n"
     ]
    }
   ],
   "source": [
    "df = df.dropna(subset=['gamble', 'cooked'])\n",
    "gamble_rare = df[(df['gamble'].str.lower() == 'yes') & (df['cooked'].str.lower() == 'rare')]\n",
    "count_gamble_rare = len(gamble_rare)\n",
    "print(f\"Number of people who gamble and order their steak rare: {count_gamble_rare}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "87df3b25-3df9-42a8-884f-2a9c1a362bf4",
   "metadata": {},
   "source": [
    "## Third Research Question: *Do people (males and females) who smoke also order their steak rare?*\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f20e80e3-f582-4422-ba20-5ff133730a79",
   "metadata": {},
   "source": [
    "### Methods\n",
    "*Explain how you will approach this research question below. Consider the following:* \n",
    "  - *Which aspects of the dataset will you use?* \n",
    "  - *How will you reorganize/store the data?* \n",
    "  - *What data science tools/functions will you use and why?* \n",
    "\n",
    "✏️ *Write your answer below:*\n",
    "\n",
    "**I will use the columns Smoke/Cooked to answer this question.\n",
    "I will...\n",
    "\n",
    "-get the value of people who smoke\n",
    "-get the value of people who order steak rare\n",
    "-get the value of people who do both smoke and order their steak rare\n",
    "\n",
    "I will use pandas to handle my data (as data frames), seaborne to create visualizations\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e3a6ce78-a232-440d-be07-d5263b922bd7",
   "metadata": {},
   "source": [
    "# Results "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fdf13331-0905-49a9-9da6-97124c967248",
   "metadata": {},
   "source": [
    "### Number of people who smoke\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "22f25f57-c47a-4b73-9fc6-12a5dcd85d2f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "smoke\n",
       "No     356\n",
       "Yes     72\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "steak.smoke.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "2377f2bc-3aa3-4d92-a128-c4cc9eaf7d35",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='smoke', ylabel='Count'>"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 17848 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.histplot(data=steak, x=\"smoke\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "baefe767-40fb-4afe-ae12-2374ce33ece4",
   "metadata": {},
   "source": [
    "### Number of people who like their steak rare\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "2e62dead-0ed2-422b-abdb-c0d359732689",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "cooked\n",
       "Medium rare    166\n",
       "Medium         132\n",
       "Medium Well     75\n",
       "Well            36\n",
       "Rare            23\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "steak.cooked.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "09aec01a-465f-49e7-8b2f-f6e3c74720da",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='cooked', ylabel='Count'>"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 21984 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.histplot(data=steak, x=\"cooked\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ee1b058c-71de-4141-b9e6-c1e66ebb6033",
   "metadata": {},
   "source": [
    "### Number of people who like their steak rare, and who smoke"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "6abbe66a-565d-47a1-a6b0-b676c0362261",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "smoke  cooked     \n",
      "No     Medium         111\n",
      "       Medium Well     61\n",
      "       Medium rare    136\n",
      "       Rare            16\n",
      "       Well            30\n",
      "Yes    Medium          20\n",
      "       Medium Well     11\n",
      "       Medium rare     30\n",
      "       Rare             6\n",
      "       Well             5\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "counts = df.groupby([\"smoke\", 'cooked']).size()\n",
    "print(counts)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "4751cff3-a23a-449d-b8f3-c52072d02768",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='smoke', ylabel='count'>"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 28268 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.countplot(x='smoke', hue='cooked', data=df)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "81274425-b884-4604-a2d4-7f2cc6b4a1c2",
   "metadata": {},
   "source": [
    "### Number of people who like their steak rare, and who do all 3 risky behaviors(smoke, drink, gamble)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "8817c157-0528-47c7-8680-c886dd5499f4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of people who smoke, drink, and gamble who order their steak rare: 5\n"
     ]
    }
   ],
   "source": [
    "df = df.dropna(subset=['smoke', 'drink', 'gamble', 'cooked'])\n",
    "smoke_drink_gamble_rare = df[\n",
    "    (df['smoke'].str.lower() == 'yes') &\n",
    "    (df['drink'].str.lower() == 'yes') &\n",
    "    (df['gamble'].str.lower() == 'yes') &\n",
    "    (df['cooked'].str.lower() == 'rare')\n",
    "]\n",
    "count_smoke_drink_gamble_rare = len(smoke_drink_gamble_rare)\n",
    "print(f\"Number of people who smoke, drink, and gamble who order their steak rare: {count_smoke_drink_gamble_rare}\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "beneficial-invasion",
   "metadata": {},
   "source": [
    "## Summary"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "about-raise",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "**OVERARCHING QUESTION**\n",
    "*DO PEOPLE WHO EXIBIT RISKY BEHAVIORS (SMOKING, GAMBLING, DRINKING) ORDER THEIR STEAK IN THE SAME RISKY MANNER AS THEIR BEAHVIORS (RARE). IS THERE A RELATIONSHIP BETWEEN THE TWO?*\n",
    "\n",
    "## *Findings \n",
    "-The number of total people in the survey was **432** \n",
    "\n",
    "-The number of people who smoke was **72** or **17%** of people in survey\n",
    "\n",
    "-The number of people who drink was **339** or **78%** of people in survey\n",
    "\n",
    "-The number of people who gamble was **216** or **50%** of people in survey\n",
    "\n",
    "-The number of people that order their steak rare was **23** or **5%** \n",
    "\n",
    "-The number of people who smoke and order steak rare was **6** or **1%** of people in survey\n",
    "\n",
    "-The number of people who drink and order steak rare was **19** or **4%** of people in survey\n",
    "\n",
    "-The number of people who Gamble and order steak rare was **12** or **3%** of people in survey\n",
    "\n",
    "# The most surprising stat was that the Number of people who do all 3 risky behaviors (smoke, drink, gamble) and order steak rare was **5** or **1%*\n",
    "\n",
    "\n",
    "\n",
    "**What did I learn about my data?**\n",
    "I learned that you can extract a bunch of different data about a survey. This was kind of a silly survey, but fun to see the results. What I learned was that out of small sample size of 432 people, doing risky behaviors such as smoking, drinking, and gambling, have nothing to do with food choices, specifically risky food choices such as ordering steak rare.\n",
    "\n",
    "**Did the results make sense?**\n",
    "Yes. The results made sense to me in the fact that I came in with a preconceived notion that the two wouldnt be related. What would have been interesting would be if you did a study between people who do risky behaviors who also live shorter lives.\n",
    "\n",
    "**What was most surprising?**\n",
    "# The most surprising stat was that the Number of people who do all 3 risky behaviors (smoke, drink, gamble) and order steak rare was **5** or **1%*\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "infectious-symbol",
   "metadata": {},
   "source": [
    "# Discussion"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bearing-stadium",
   "metadata": {},
   "source": [
    "*It's important to recognize the limitations of our research.\n",
    "Consider the following:*\n",
    "\n",
    "**Do the results give an accurate depiction of your research question? Why or why not?**\n",
    "Yes becasue it answers the question.\n",
    "  \n",
    "**What were limitations of your datset?**\n",
    "I only had a small sample size.\n",
    "\n",
    "**Are there any known biases in the data?**\n",
    "I dont believe so.\n",
    "\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "cell_metadata_json": true,
   "text_representation": {
    "extension": ".Rmd",
    "format_name": "rmarkdown",
    "format_version": "1.2",
    "jupytext_version": "1.9.1"
   }
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.12.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
