{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introducing Thanksgiving Dinner Data"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" RespondentID | \n",
" 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",
" ... | \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? | \n",
" Age | \n",
" What is your gender? | \n",
" How much total combined money did all members of your HOUSEHOLD earn last year? | \n",
" US Region | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 4337954960 | \n",
" Yes | \n",
" Turkey | \n",
" NaN | \n",
" Baked | \n",
" NaN | \n",
" Bread-based | \n",
" NaN | \n",
" None | \n",
" NaN | \n",
" ... | \n",
" Yes | \n",
" No | \n",
" No | \n",
" No | \n",
" NaN | \n",
" Suburban | \n",
" 18 - 29 | \n",
" Male | \n",
" $75,000 to $99,999 | \n",
" Middle Atlantic | \n",
"
\n",
" \n",
" 1 | \n",
" 4337951949 | \n",
" Yes | \n",
" Turkey | \n",
" NaN | \n",
" Baked | \n",
" NaN | \n",
" Bread-based | \n",
" NaN | \n",
" Other (please specify) | \n",
" Homemade cranberry gelatin ring | \n",
" ... | \n",
" No | \n",
" No | \n",
" Yes | \n",
" No | \n",
" NaN | \n",
" Rural | \n",
" 18 - 29 | \n",
" Female | \n",
" $50,000 to $74,999 | \n",
" East South Central | \n",
"
\n",
" \n",
" 2 | \n",
" 4337935621 | \n",
" Yes | \n",
" Turkey | \n",
" NaN | \n",
" Roasted | \n",
" NaN | \n",
" Rice-based | \n",
" NaN | \n",
" Homemade | \n",
" NaN | \n",
" ... | \n",
" Yes | \n",
" Yes | \n",
" Yes | \n",
" No | \n",
" NaN | \n",
" Suburban | \n",
" 18 - 29 | \n",
" Male | \n",
" $0 to $9,999 | \n",
" Mountain | \n",
"
\n",
" \n",
" 3 | \n",
" 4337933040 | \n",
" Yes | \n",
" Turkey | \n",
" NaN | \n",
" Baked | \n",
" NaN | \n",
" Bread-based | \n",
" NaN | \n",
" Homemade | \n",
" NaN | \n",
" ... | \n",
" Yes | \n",
" No | \n",
" No | \n",
" No | \n",
" NaN | \n",
" Urban | \n",
" 30 - 44 | \n",
" Male | \n",
" $200,000 and up | \n",
" Pacific | \n",
"
\n",
" \n",
" 4 | \n",
" 4337931983 | \n",
" Yes | \n",
" Tofurkey | \n",
" NaN | \n",
" Baked | \n",
" NaN | \n",
" Bread-based | \n",
" NaN | \n",
" Canned | \n",
" NaN | \n",
" ... | \n",
" Yes | \n",
" No | \n",
" No | \n",
" No | \n",
" NaN | \n",
" Urban | \n",
" 30 - 44 | \n",
" Male | \n",
" $100,000 to $124,999 | \n",
" Pacific | \n",
"
\n",
" \n",
"
\n",
"
5 rows × 65 columns
\n",
"
"
],
"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": 1,
"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": 2,
"metadata": {},
"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": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data.columns"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Filtering out Rows from A DataFrame"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Yes 980\n",
"No 78\n",
"Name: Do you celebrate Thanksgiving?, dtype: int64"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[\"Do you celebrate Thanksgiving?\"].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"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": 5,
"metadata": {},
"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": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[\"What is typically the main dish at your Thanksgiving dinner?\"].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"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": 6,
"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": [
"# Determining Which Pies People Eat"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"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": 7,
"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": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False 876\n",
"True 104\n",
"dtype: int64"
]
},
"execution_count": 8,
"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": 9,
"metadata": {},
"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": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[\"Age\"].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"count 947.000000\n",
"mean 40.089757\n",
"std 15.352014\n",
"min 18.000000\n",
"25% 30.000000\n",
"50% 45.000000\n",
"75% 60.000000\n",
"max 60.000000\n",
"Name: int_age, dtype: float64"
]
},
"execution_count": 10,
"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 the age groups of respondents are fairly evenly distributed."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Converting Income to Numeric"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"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": 11,
"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": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"count 829.000000\n",
"mean 75965.018094\n",
"std 59068.636748\n",
"min 0.000000\n",
"25% 25000.000000\n",
"50% 75000.000000\n",
"75% 100000.000000\n",
"max 200000.000000\n",
"Name: int_income, dtype: float64"
]
},
"execution_count": 12,
"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": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Thanksgiving is happening at my home--I won't travel at all 281\n",
"Thanksgiving is local--it will take place in the town I live in 203\n",
"Thanksgiving is out of town but not too far--it's a drive of a few hours or less 150\n",
"Thanksgiving is out of town and far away--I have to drive several hours or fly 55\n",
"Name: How far will you travel for Thanksgiving?, dtype: int64"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[data[\"int_income\"] < 150000][\"How far will you travel for Thanksgiving?\"].value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"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": 14,
"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": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" Have you ever attended a \"Friendsgiving?\" | \n",
" No | \n",
" Yes | \n",
"
\n",
" \n",
" Have you ever tried to meet up with hometown friends on Thanksgiving night? | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" No | \n",
" 42.283702 | \n",
" 37.010526 | \n",
"
\n",
" \n",
" Yes | \n",
" 41.475410 | \n",
" 33.976744 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"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": 15,
"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": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" Have you ever attended a \"Friendsgiving?\" | \n",
" No | \n",
" Yes | \n",
"
\n",
" \n",
" Have you ever tried to meet up with hometown friends on Thanksgiving night? | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" No | \n",
" 78914.549654 | \n",
" 72894.736842 | \n",
"
\n",
" \n",
" Yes | \n",
" 78750.000000 | \n",
" 66019.736842 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"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": 16,
"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 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.8.5"
},
"widgets": {
"state": {},
"version": "1.1.1"
}
},
"nbformat": 4,
"nbformat_minor": 1
}