{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"___\n",
"\n",
" \n",
"___\n",
"# Seaborn Exercises\n",
"\n",
"Time to practice your new seaborn skills! Try to recreate the plots below (don't worry about color schemes, just the plot itself."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The Data\n",
"\n",
"We will be working with a famous titanic data set for these exercises. Later on in the Machine Learning section of the course, we will revisit this data, and use it to predict survival rates of passengers. For now, we'll just focus on the visualization of the data with seaborn:"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"sns.set_style('whitegrid')"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"titanic = sns.load_dataset('titanic')"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"
\n", " | survived | \n", "pclass | \n", "sex | \n", "age | \n", "sibsp | \n", "parch | \n", "fare | \n", "embarked | \n", "class | \n", "who | \n", "adult_male | \n", "deck | \n", "embark_town | \n", "alive | \n", "alone | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0 | \n", "3 | \n", "male | \n", "22.0 | \n", "1 | \n", "0 | \n", "7.2500 | \n", "S | \n", "Third | \n", "man | \n", "True | \n", "NaN | \n", "Southampton | \n", "no | \n", "False | \n", "
1 | \n", "1 | \n", "1 | \n", "female | \n", "38.0 | \n", "1 | \n", "0 | \n", "71.2833 | \n", "C | \n", "First | \n", "woman | \n", "False | \n", "C | \n", "Cherbourg | \n", "yes | \n", "False | \n", "
2 | \n", "1 | \n", "3 | \n", "female | \n", "26.0 | \n", "0 | \n", "0 | \n", "7.9250 | \n", "S | \n", "Third | \n", "woman | \n", "False | \n", "NaN | \n", "Southampton | \n", "yes | \n", "True | \n", "
3 | \n", "1 | \n", "1 | \n", "female | \n", "35.0 | \n", "1 | \n", "0 | \n", "53.1000 | \n", "S | \n", "First | \n", "woman | \n", "False | \n", "C | \n", "Southampton | \n", "yes | \n", "False | \n", "
4 | \n", "0 | \n", "3 | \n", "male | \n", "35.0 | \n", "0 | \n", "0 | \n", "8.0500 | \n", "S | \n", "Third | \n", "man | \n", "True | \n", "NaN | \n", "Southampton | \n", "no | \n", "True | \n", "