Introduction to Python - Null Values
rpi.analyticsdojo.com
Running Code using Kaggle Notebooks
- Kaggle utilizes Docker to create a fully functional environment for hosting competitions in data science.
- You could download/run this locally or run it online.
- Kaggle has created an incredible resource for learning analytics. You can view a number of toy examples that can be used to understand data science and also compete in real problems faced by top companies.
```!wget https://raw.githubusercontent.com/rpi-techfundamentals/spring2019-materials/master/input/train.csv !wget https://raw.githubusercontent.com/rpi-techfundamentals/spring2019-materials/master/input/test.csv
</div>
<div class="output_wrapper" markdown="1">
<div class="output_subarea" markdown="1">
{:.output_stream}
–2019-01-24 15:46:15– https://raw.githubusercontent.com/rpi-techfundamentals/spring2019-materials/master/input/train.csv Resolving raw.githubusercontent.com (raw.githubusercontent.com)… 151.101.0.133, 151.101.64.133, 151.101.128.133, … Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 61194 (60K) [text/plain] Saving to: ‘train.csv’
train.csv 100%[===================>] 59.76K –.-KB/s in 0.01s
2019-01-24 15:46:15 (4.14 MB/s) - ‘train.csv’ saved [61194/61194]
–2019-01-24 15:46:16– https://raw.githubusercontent.com/rpi-techfundamentals/spring2019-materials/master/input/test.csv Resolving raw.githubusercontent.com (raw.githubusercontent.com)… 151.101.0.133, 151.101.64.133, 151.101.128.133, … Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 28629 (28K) [text/plain] Saving to: ‘test.csv’
test.csv 100%[===================>] 27.96K –.-KB/s in 0.007s
2019-01-24 15:46:16 (3.88 MB/s) - ‘test.csv’ saved [28629/28629]
</div>
</div>
</div>
### Null Values Typical When Working with Real Data
- Null values `NaN` in Pandas
<div markdown="1" class="cell code_cell">
<div class="input_area" markdown="1">
```import numpy as np
import pandas as pd
# Input data files are available in the "../input/" directory.
# Let's input them into a Pandas DataFrame
train = pd.read_csv("train.csv")
test = pd.read_csv("test.csv")
```#Let’s get some general s totalRows=len(train.index) print(“There are “, totalRows, “ so totalRows-count is equal to missing variables.”) print(train.describe()) print(train.columns)
</div>
<div class="output_wrapper" markdown="1">
<div class="output_subarea" markdown="1">
{:.output_stream}
There are 891 so totalRows-count is equal to missing variables.
PassengerId Survived Pclass Age SibSp \
count 891.000000 891.000000 891.000000 714.000000 891.000000
mean 446.000000 0.383838 2.308642 29.699118 0.523008
std 257.353842 0.486592 0.836071 14.526497 1.102743
min 1.000000 0.000000 1.000000 0.420000 0.000000
25% 223.500000 0.000000 2.000000 20.125000 0.000000
50% 446.000000 0.000000 3.000000 28.000000 0.000000
75% 668.500000 1.000000 3.000000 38.000000 1.000000
max 891.000000 1.000000 3.000000 80.000000 8.000000
Parch Fare count 891.000000 891.000000 mean 0.381594 32.204208 std 0.806057 49.693429 min 0.000000 0.000000 25% 0.000000 7.910400 50% 0.000000 14.454200 75% 0.000000 31.000000 max 6.000000 512.329200 Index(['PassengerId', 'Survived', 'Pclass', 'Name', 'Sex', 'Age', 'SibSp',
'Parch', 'Ticket', 'Fare', 'Cabin', 'Embarked'],
dtype='object') ```
</div>
```# We are going to do operations on thes to show the number of missing variables. train.isnull().sum()
</div>
<div class="output_wrapper" markdown="1">
<div class="output_subarea" markdown="1">
{:.output_data_text}
PassengerId 0 Survived 0 Pclass 0 Name 0 Sex 0 Age 177 SibSp 0 Parch 0 Ticket 0 Fare 0 Cabin 687 Embarked 2 dtype: int64
</div>
</div>
</div>
### Dropping NA
- If we drop all NA values, this can dramatically reduce our dataset.
- Here while there are 891 rows total, there are only 183 complete rows
- `dropna()` and `fillna()` are 2 method for dealing with this, but they should be used with caution.
- [Fillna documentation](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.fillna.html)
- [Dropna documentation](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.dropna.html)
<div markdown="1" class="cell code_cell">
<div class="input_area" markdown="1">
```# This will drop all rows in which there is any missing values
traindrop=train.dropna()
print(len(traindrop.index))
print(traindrop.isnull().sum())
```# This will drop all rows in which there is any missing values trainfill=train.fillna(0) #This will just fill all values with nulls. Probably not what we want. print(len(trainfill.index)) print(traindrop.isnull().sum())
forward-fill previous value forward.
train.fillna(method=’ffill’)
forward-fill previous value forward.
train.fillna(method=’bfill’)
</div>
<div class="output_wrapper" markdown="1">
<div class="output_subarea" markdown="1">
{:.output_stream}
891 PassengerId 0 Survived 0 Pclass 0 Name 0 Sex 0 Age 0 SibSp 0 Parch 0 Ticket 0 Fare 0 Cabin 0 Embarked 0 dtype: int64
</div>
</div>
<div class="output_wrapper" markdown="1">
<div class="output_subarea" markdown="1">
<div markdown="0" class="output output_html">
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>PassengerId</th>
<th>Survived</th>
<th>Pclass</th>
<th>Name</th>
<th>Sex</th>
<th>Age</th>
<th>SibSp</th>
<th>Parch</th>
<th>Ticket</th>
<th>Fare</th>
<th>Cabin</th>
<th>Embarked</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>1</td>
<td>0</td>
<td>3</td>
<td>Braund, Mr. Owen Harris</td>
<td>male</td>
<td>22.0</td>
<td>1</td>
<td>0</td>
<td>A/5 21171</td>
<td>7.2500</td>
<td>C85</td>
<td>S</td>
</tr>
<tr>
<th>1</th>
<td>2</td>
<td>1</td>
<td>1</td>
<td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>
<td>female</td>
<td>38.0</td>
<td>1</td>
<td>0</td>
<td>PC 17599</td>
<td>71.2833</td>
<td>C85</td>
<td>C</td>
</tr>
<tr>
<th>2</th>
<td>3</td>
<td>1</td>
<td>3</td>
<td>Heikkinen, Miss. Laina</td>
<td>female</td>
<td>26.0</td>
<td>0</td>
<td>0</td>
<td>STON/O2. 3101282</td>
<td>7.9250</td>
<td>C123</td>
<td>S</td>
</tr>
<tr>
<th>3</th>
<td>4</td>
<td>1</td>
<td>1</td>
<td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>
<td>female</td>
<td>35.0</td>
<td>1</td>
<td>0</td>
<td>113803</td>
<td>53.1000</td>
<td>C123</td>
<td>S</td>
</tr>
<tr>
<th>4</th>
<td>5</td>
<td>0</td>
<td>3</td>
<td>Allen, Mr. William Henry</td>
<td>male</td>
<td>35.0</td>
<td>0</td>
<td>0</td>
<td>373450</td>
<td>8.0500</td>
<td>E46</td>
<td>S</td>
</tr>
<tr>
<th>5</th>
<td>6</td>
<td>0</td>
<td>3</td>
<td>Moran, Mr. James</td>
<td>male</td>
<td>54.0</td>
<td>0</td>
<td>0</td>
<td>330877</td>
<td>8.4583</td>
<td>E46</td>
<td>Q</td>
</tr>
<tr>
<th>6</th>
<td>7</td>
<td>0</td>
<td>1</td>
<td>McCarthy, Mr. Timothy J</td>
<td>male</td>
<td>54.0</td>
<td>0</td>
<td>0</td>
<td>17463</td>
<td>51.8625</td>
<td>E46</td>
<td>S</td>
</tr>
<tr>
<th>7</th>
<td>8</td>
<td>0</td>
<td>3</td>
<td>Palsson, Master. Gosta Leonard</td>
<td>male</td>
<td>2.0</td>
<td>3</td>
<td>1</td>
<td>349909</td>
<td>21.0750</td>
<td>G6</td>
<td>S</td>
</tr>
<tr>
<th>8</th>
<td>9</td>
<td>1</td>
<td>3</td>
<td>Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg)</td>
<td>female</td>
<td>27.0</td>
<td>0</td>
<td>2</td>
<td>347742</td>
<td>11.1333</td>
<td>G6</td>
<td>S</td>
</tr>
<tr>
<th>9</th>
<td>10</td>
<td>1</td>
<td>2</td>
<td>Nasser, Mrs. Nicholas (Adele Achem)</td>
<td>female</td>
<td>14.0</td>
<td>1</td>
<td>0</td>
<td>237736</td>
<td>30.0708</td>
<td>G6</td>
<td>C</td>
</tr>
<tr>
<th>10</th>
<td>11</td>
<td>1</td>
<td>3</td>
<td>Sandstrom, Miss. Marguerite Rut</td>
<td>female</td>
<td>4.0</td>
<td>1</td>
<td>1</td>
<td>PP 9549</td>
<td>16.7000</td>
<td>G6</td>
<td>S</td>
</tr>
<tr>
<th>11</th>
<td>12</td>
<td>1</td>
<td>1</td>
<td>Bonnell, Miss. Elizabeth</td>
<td>female</td>
<td>58.0</td>
<td>0</td>
<td>0</td>
<td>113783</td>
<td>26.5500</td>
<td>C103</td>
<td>S</td>
</tr>
<tr>
<th>12</th>
<td>13</td>
<td>0</td>
<td>3</td>
<td>Saundercock, Mr. William Henry</td>
<td>male</td>
<td>20.0</td>
<td>0</td>
<td>0</td>
<td>A/5. 2151</td>
<td>8.0500</td>
<td>D56</td>
<td>S</td>
</tr>
<tr>
<th>13</th>
<td>14</td>
<td>0</td>
<td>3</td>
<td>Andersson, Mr. Anders Johan</td>
<td>male</td>
<td>39.0</td>
<td>1</td>
<td>5</td>
<td>347082</td>
<td>31.2750</td>
<td>D56</td>
<td>S</td>
</tr>
<tr>
<th>14</th>
<td>15</td>
<td>0</td>
<td>3</td>
<td>Vestrom, Miss. Hulda Amanda Adolfina</td>
<td>female</td>
<td>14.0</td>
<td>0</td>
<td>0</td>
<td>350406</td>
<td>7.8542</td>
<td>D56</td>
<td>S</td>
</tr>
<tr>
<th>15</th>
<td>16</td>
<td>1</td>
<td>2</td>
<td>Hewlett, Mrs. (Mary D Kingcome)</td>
<td>female</td>
<td>55.0</td>
<td>0</td>
<td>0</td>
<td>248706</td>
<td>16.0000</td>
<td>D56</td>
<td>S</td>
</tr>
<tr>
<th>16</th>
<td>17</td>
<td>0</td>
<td>3</td>
<td>Rice, Master. Eugene</td>
<td>male</td>
<td>2.0</td>
<td>4</td>
<td>1</td>
<td>382652</td>
<td>29.1250</td>
<td>D56</td>
<td>Q</td>
</tr>
<tr>
<th>17</th>
<td>18</td>
<td>1</td>
<td>2</td>
<td>Williams, Mr. Charles Eugene</td>
<td>male</td>
<td>31.0</td>
<td>0</td>
<td>0</td>
<td>244373</td>
<td>13.0000</td>
<td>D56</td>
<td>S</td>
</tr>
<tr>
<th>18</th>
<td>19</td>
<td>0</td>
<td>3</td>
<td>Vander Planke, Mrs. Julius (Emelia Maria Vande...</td>
<td>female</td>
<td>31.0</td>
<td>1</td>
<td>0</td>
<td>345763</td>
<td>18.0000</td>
<td>D56</td>
<td>S</td>
</tr>
<tr>
<th>19</th>
<td>20</td>
<td>1</td>
<td>3</td>
<td>Masselmani, Mrs. Fatima</td>
<td>female</td>
<td>35.0</td>
<td>0</td>
<td>0</td>
<td>2649</td>
<td>7.2250</td>
<td>D56</td>
<td>C</td>
</tr>
<tr>
<th>20</th>
<td>21</td>
<td>0</td>
<td>2</td>
<td>Fynney, Mr. Joseph J</td>
<td>male</td>
<td>35.0</td>
<td>0</td>
<td>0</td>
<td>239865</td>
<td>26.0000</td>
<td>D56</td>
<td>S</td>
</tr>
<tr>
<th>21</th>
<td>22</td>
<td>1</td>
<td>2</td>
<td>Beesley, Mr. Lawrence</td>
<td>male</td>
<td>34.0</td>
<td>0</td>
<td>0</td>
<td>248698</td>
<td>13.0000</td>
<td>D56</td>
<td>S</td>
</tr>
<tr>
<th>22</th>
<td>23</td>
<td>1</td>
<td>3</td>
<td>McGowan, Miss. Anna "Annie"</td>
<td>female</td>
<td>15.0</td>
<td>0</td>
<td>0</td>
<td>330923</td>
<td>8.0292</td>
<td>A6</td>
<td>Q</td>
</tr>
<tr>
<th>23</th>
<td>24</td>
<td>1</td>
<td>1</td>
<td>Sloper, Mr. William Thompson</td>
<td>male</td>
<td>28.0</td>
<td>0</td>
<td>0</td>
<td>113788</td>
<td>35.5000</td>
<td>A6</td>
<td>S</td>
</tr>
<tr>
<th>24</th>
<td>25</td>
<td>0</td>
<td>3</td>
<td>Palsson, Miss. Torborg Danira</td>
<td>female</td>
<td>8.0</td>
<td>3</td>
<td>1</td>
<td>349909</td>
<td>21.0750</td>
<td>C23 C25 C27</td>
<td>S</td>
</tr>
<tr>
<th>25</th>
<td>26</td>
<td>1</td>
<td>3</td>
<td>Asplund, Mrs. Carl Oscar (Selma Augusta Emilia...</td>
<td>female</td>
<td>38.0</td>
<td>1</td>
<td>5</td>
<td>347077</td>
<td>31.3875</td>
<td>C23 C25 C27</td>
<td>S</td>
</tr>
<tr>
<th>26</th>
<td>27</td>
<td>0</td>
<td>3</td>
<td>Emir, Mr. Farred Chehab</td>
<td>male</td>
<td>19.0</td>
<td>0</td>
<td>0</td>
<td>2631</td>
<td>7.2250</td>
<td>C23 C25 C27</td>
<td>C</td>
</tr>
<tr>
<th>27</th>
<td>28</td>
<td>0</td>
<td>1</td>
<td>Fortune, Mr. Charles Alexander</td>
<td>male</td>
<td>19.0</td>
<td>3</td>
<td>2</td>
<td>19950</td>
<td>263.0000</td>
<td>C23 C25 C27</td>
<td>S</td>
</tr>
<tr>
<th>28</th>
<td>29</td>
<td>1</td>
<td>3</td>
<td>O'Dwyer, Miss. Ellen "Nellie"</td>
<td>female</td>
<td>40.0</td>
<td>0</td>
<td>0</td>
<td>330959</td>
<td>7.8792</td>
<td>B78</td>
<td>Q</td>
</tr>
<tr>
<th>29</th>
<td>30</td>
<td>0</td>
<td>3</td>
<td>Todoroff, Mr. Lalio</td>
<td>male</td>
<td>40.0</td>
<td>0</td>
<td>0</td>
<td>349216</td>
<td>7.8958</td>
<td>B78</td>
<td>S</td>
</tr>
<tr>
<th>...</th>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
<tr>
<th>861</th>
<td>862</td>
<td>0</td>
<td>2</td>
<td>Giles, Mr. Frederick Edward</td>
<td>male</td>
<td>21.0</td>
<td>1</td>
<td>0</td>
<td>28134</td>
<td>11.5000</td>
<td>D17</td>
<td>S</td>
</tr>
<tr>
<th>862</th>
<td>863</td>
<td>1</td>
<td>1</td>
<td>Swift, Mrs. Frederick Joel (Margaret Welles Ba...</td>
<td>female</td>
<td>48.0</td>
<td>0</td>
<td>0</td>
<td>17466</td>
<td>25.9292</td>
<td>D17</td>
<td>S</td>
</tr>
<tr>
<th>863</th>
<td>864</td>
<td>0</td>
<td>3</td>
<td>Sage, Miss. Dorothy Edith "Dolly"</td>
<td>female</td>
<td>24.0</td>
<td>8</td>
<td>2</td>
<td>CA. 2343</td>
<td>69.5500</td>
<td>A24</td>
<td>S</td>
</tr>
<tr>
<th>864</th>
<td>865</td>
<td>0</td>
<td>2</td>
<td>Gill, Mr. John William</td>
<td>male</td>
<td>24.0</td>
<td>0</td>
<td>0</td>
<td>233866</td>
<td>13.0000</td>
<td>A24</td>
<td>S</td>
</tr>
<tr>
<th>865</th>
<td>866</td>
<td>1</td>
<td>2</td>
<td>Bystrom, Mrs. (Karolina)</td>
<td>female</td>
<td>42.0</td>
<td>0</td>
<td>0</td>
<td>236852</td>
<td>13.0000</td>
<td>A24</td>
<td>S</td>
</tr>
<tr>
<th>866</th>
<td>867</td>
<td>1</td>
<td>2</td>
<td>Duran y More, Miss. Asuncion</td>
<td>female</td>
<td>27.0</td>
<td>1</td>
<td>0</td>
<td>SC/PARIS 2149</td>
<td>13.8583</td>
<td>A24</td>
<td>C</td>
</tr>
<tr>
<th>867</th>
<td>868</td>
<td>0</td>
<td>1</td>
<td>Roebling, Mr. Washington Augustus II</td>
<td>male</td>
<td>31.0</td>
<td>0</td>
<td>0</td>
<td>PC 17590</td>
<td>50.4958</td>
<td>A24</td>
<td>S</td>
</tr>
<tr>
<th>868</th>
<td>869</td>
<td>0</td>
<td>3</td>
<td>van Melkebeke, Mr. Philemon</td>
<td>male</td>
<td>4.0</td>
<td>0</td>
<td>0</td>
<td>345777</td>
<td>9.5000</td>
<td>D35</td>
<td>S</td>
</tr>
<tr>
<th>869</th>
<td>870</td>
<td>1</td>
<td>3</td>
<td>Johnson, Master. Harold Theodor</td>
<td>male</td>
<td>4.0</td>
<td>1</td>
<td>1</td>
<td>347742</td>
<td>11.1333</td>
<td>D35</td>
<td>S</td>
</tr>
<tr>
<th>870</th>
<td>871</td>
<td>0</td>
<td>3</td>
<td>Balkic, Mr. Cerin</td>
<td>male</td>
<td>26.0</td>
<td>0</td>
<td>0</td>
<td>349248</td>
<td>7.8958</td>
<td>D35</td>
<td>S</td>
</tr>
<tr>
<th>871</th>
<td>872</td>
<td>1</td>
<td>1</td>
<td>Beckwith, Mrs. Richard Leonard (Sallie Monypeny)</td>
<td>female</td>
<td>47.0</td>
<td>1</td>
<td>1</td>
<td>11751</td>
<td>52.5542</td>
<td>D35</td>
<td>S</td>
</tr>
<tr>
<th>872</th>
<td>873</td>
<td>0</td>
<td>1</td>
<td>Carlsson, Mr. Frans Olof</td>
<td>male</td>
<td>33.0</td>
<td>0</td>
<td>0</td>
<td>695</td>
<td>5.0000</td>
<td>B51 B53 B55</td>
<td>S</td>
</tr>
<tr>
<th>873</th>
<td>874</td>
<td>0</td>
<td>3</td>
<td>Vander Cruyssen, Mr. Victor</td>
<td>male</td>
<td>47.0</td>
<td>0</td>
<td>0</td>
<td>345765</td>
<td>9.0000</td>
<td>C50</td>
<td>S</td>
</tr>
<tr>
<th>874</th>
<td>875</td>
<td>1</td>
<td>2</td>
<td>Abelson, Mrs. Samuel (Hannah Wizosky)</td>
<td>female</td>
<td>28.0</td>
<td>1</td>
<td>0</td>
<td>P/PP 3381</td>
<td>24.0000</td>
<td>C50</td>
<td>C</td>
</tr>
<tr>
<th>875</th>
<td>876</td>
<td>1</td>
<td>3</td>
<td>Najib, Miss. Adele Kiamie "Jane"</td>
<td>female</td>
<td>15.0</td>
<td>0</td>
<td>0</td>
<td>2667</td>
<td>7.2250</td>
<td>C50</td>
<td>C</td>
</tr>
<tr>
<th>876</th>
<td>877</td>
<td>0</td>
<td>3</td>
<td>Gustafsson, Mr. Alfred Ossian</td>
<td>male</td>
<td>20.0</td>
<td>0</td>
<td>0</td>
<td>7534</td>
<td>9.8458</td>
<td>C50</td>
<td>S</td>
</tr>
<tr>
<th>877</th>
<td>878</td>
<td>0</td>
<td>3</td>
<td>Petroff, Mr. Nedelio</td>
<td>male</td>
<td>19.0</td>
<td>0</td>
<td>0</td>
<td>349212</td>
<td>7.8958</td>
<td>C50</td>
<td>S</td>
</tr>
<tr>
<th>878</th>
<td>879</td>
<td>0</td>
<td>3</td>
<td>Laleff, Mr. Kristo</td>
<td>male</td>
<td>56.0</td>
<td>0</td>
<td>0</td>
<td>349217</td>
<td>7.8958</td>
<td>C50</td>
<td>S</td>
</tr>
<tr>
<th>879</th>
<td>880</td>
<td>1</td>
<td>1</td>
<td>Potter, Mrs. Thomas Jr (Lily Alexenia Wilson)</td>
<td>female</td>
<td>56.0</td>
<td>0</td>
<td>1</td>
<td>11767</td>
<td>83.1583</td>
<td>C50</td>
<td>C</td>
</tr>
<tr>
<th>880</th>
<td>881</td>
<td>1</td>
<td>2</td>
<td>Shelley, Mrs. William (Imanita Parrish Hall)</td>
<td>female</td>
<td>25.0</td>
<td>0</td>
<td>1</td>
<td>230433</td>
<td>26.0000</td>
<td>B42</td>
<td>S</td>
</tr>
<tr>
<th>881</th>
<td>882</td>
<td>0</td>
<td>3</td>
<td>Markun, Mr. Johann</td>
<td>male</td>
<td>33.0</td>
<td>0</td>
<td>0</td>
<td>349257</td>
<td>7.8958</td>
<td>B42</td>
<td>S</td>
</tr>
<tr>
<th>882</th>
<td>883</td>
<td>0</td>
<td>3</td>
<td>Dahlberg, Miss. Gerda Ulrika</td>
<td>female</td>
<td>22.0</td>
<td>0</td>
<td>0</td>
<td>7552</td>
<td>10.5167</td>
<td>B42</td>
<td>S</td>
</tr>
<tr>
<th>883</th>
<td>884</td>
<td>0</td>
<td>2</td>
<td>Banfield, Mr. Frederick James</td>
<td>male</td>
<td>28.0</td>
<td>0</td>
<td>0</td>
<td>C.A./SOTON 34068</td>
<td>10.5000</td>
<td>B42</td>
<td>S</td>
</tr>
<tr>
<th>884</th>
<td>885</td>
<td>0</td>
<td>3</td>
<td>Sutehall, Mr. Henry Jr</td>
<td>male</td>
<td>25.0</td>
<td>0</td>
<td>0</td>
<td>SOTON/OQ 392076</td>
<td>7.0500</td>
<td>B42</td>
<td>S</td>
</tr>
<tr>
<th>885</th>
<td>886</td>
<td>0</td>
<td>3</td>
<td>Rice, Mrs. William (Margaret Norton)</td>
<td>female</td>
<td>39.0</td>
<td>0</td>
<td>5</td>
<td>382652</td>
<td>29.1250</td>
<td>B42</td>
<td>Q</td>
</tr>
<tr>
<th>886</th>
<td>887</td>
<td>0</td>
<td>2</td>
<td>Montvila, Rev. Juozas</td>
<td>male</td>
<td>27.0</td>
<td>0</td>
<td>0</td>
<td>211536</td>
<td>13.0000</td>
<td>B42</td>
<td>S</td>
</tr>
<tr>
<th>887</th>
<td>888</td>
<td>1</td>
<td>1</td>
<td>Graham, Miss. Margaret Edith</td>
<td>female</td>
<td>19.0</td>
<td>0</td>
<td>0</td>
<td>112053</td>
<td>30.0000</td>
<td>B42</td>
<td>S</td>
</tr>
<tr>
<th>888</th>
<td>889</td>
<td>0</td>
<td>3</td>
<td>Johnston, Miss. Catherine Helen "Carrie"</td>
<td>female</td>
<td>26.0</td>
<td>1</td>
<td>2</td>
<td>W./C. 6607</td>
<td>23.4500</td>
<td>C148</td>
<td>S</td>
</tr>
<tr>
<th>889</th>
<td>890</td>
<td>1</td>
<td>1</td>
<td>Behr, Mr. Karl Howell</td>
<td>male</td>
<td>26.0</td>
<td>0</td>
<td>0</td>
<td>111369</td>
<td>30.0000</td>
<td>C148</td>
<td>C</td>
</tr>
<tr>
<th>890</th>
<td>891</td>
<td>0</td>
<td>3</td>
<td>Dooley, Mr. Patrick</td>
<td>male</td>
<td>32.0</td>
<td>0</td>
<td>0</td>
<td>370376</td>
<td>7.7500</td>
<td>NaN</td>
<td>Q</td>
</tr>
</tbody>
</table>
<p>891 rows × 12 columns</p>
</div>
</div>
</div>
</div>
</div>
### Customized Approach
- While those approaches
<div markdown="1" class="cell code_cell">
<div class="input_area" markdown="1">
```average=train.Age.mean()
print(average)
```#Let’s convert it to an int average= int(average) average
</div>
<div class="output_wrapper" markdown="1">
<div class="output_subarea" markdown="1">
{:.output_data_text}
29
</div>
</div>
</div>
<div markdown="1" class="cell code_cell">
<div class="input_area" markdown="1">
```#This will select out values that
train.Age.isnull()
```#Now we are selecting out those values train.loc[train.Age.isnull(),”Age”]=average train
</div>
<div class="output_wrapper" markdown="1">
<div class="output_subarea" markdown="1">
<div markdown="0" class="output output_html">
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>PassengerId</th>
<th>Survived</th>
<th>Pclass</th>
<th>Name</th>
<th>Sex</th>
<th>Age</th>
<th>SibSp</th>
<th>Parch</th>
<th>Ticket</th>
<th>Fare</th>
<th>Cabin</th>
<th>Embarked</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>1</td>
<td>0</td>
<td>3</td>
<td>Braund, Mr. Owen Harris</td>
<td>male</td>
<td>22.0</td>
<td>1</td>
<td>0</td>
<td>A/5 21171</td>
<td>7.2500</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>1</th>
<td>2</td>
<td>1</td>
<td>1</td>
<td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>
<td>female</td>
<td>38.0</td>
<td>1</td>
<td>0</td>
<td>PC 17599</td>
<td>71.2833</td>
<td>C85</td>
<td>C</td>
</tr>
<tr>
<th>2</th>
<td>3</td>
<td>1</td>
<td>3</td>
<td>Heikkinen, Miss. Laina</td>
<td>female</td>
<td>26.0</td>
<td>0</td>
<td>0</td>
<td>STON/O2. 3101282</td>
<td>7.9250</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>3</th>
<td>4</td>
<td>1</td>
<td>1</td>
<td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>
<td>female</td>
<td>35.0</td>
<td>1</td>
<td>0</td>
<td>113803</td>
<td>53.1000</td>
<td>C123</td>
<td>S</td>
</tr>
<tr>
<th>4</th>
<td>5</td>
<td>0</td>
<td>3</td>
<td>Allen, Mr. William Henry</td>
<td>male</td>
<td>35.0</td>
<td>0</td>
<td>0</td>
<td>373450</td>
<td>8.0500</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>5</th>
<td>6</td>
<td>0</td>
<td>3</td>
<td>Moran, Mr. James</td>
<td>male</td>
<td>29.0</td>
<td>0</td>
<td>0</td>
<td>330877</td>
<td>8.4583</td>
<td>NaN</td>
<td>Q</td>
</tr>
<tr>
<th>6</th>
<td>7</td>
<td>0</td>
<td>1</td>
<td>McCarthy, Mr. Timothy J</td>
<td>male</td>
<td>54.0</td>
<td>0</td>
<td>0</td>
<td>17463</td>
<td>51.8625</td>
<td>E46</td>
<td>S</td>
</tr>
<tr>
<th>7</th>
<td>8</td>
<td>0</td>
<td>3</td>
<td>Palsson, Master. Gosta Leonard</td>
<td>male</td>
<td>2.0</td>
<td>3</td>
<td>1</td>
<td>349909</td>
<td>21.0750</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>8</th>
<td>9</td>
<td>1</td>
<td>3</td>
<td>Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg)</td>
<td>female</td>
<td>27.0</td>
<td>0</td>
<td>2</td>
<td>347742</td>
<td>11.1333</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>9</th>
<td>10</td>
<td>1</td>
<td>2</td>
<td>Nasser, Mrs. Nicholas (Adele Achem)</td>
<td>female</td>
<td>14.0</td>
<td>1</td>
<td>0</td>
<td>237736</td>
<td>30.0708</td>
<td>NaN</td>
<td>C</td>
</tr>
<tr>
<th>10</th>
<td>11</td>
<td>1</td>
<td>3</td>
<td>Sandstrom, Miss. Marguerite Rut</td>
<td>female</td>
<td>4.0</td>
<td>1</td>
<td>1</td>
<td>PP 9549</td>
<td>16.7000</td>
<td>G6</td>
<td>S</td>
</tr>
<tr>
<th>11</th>
<td>12</td>
<td>1</td>
<td>1</td>
<td>Bonnell, Miss. Elizabeth</td>
<td>female</td>
<td>58.0</td>
<td>0</td>
<td>0</td>
<td>113783</td>
<td>26.5500</td>
<td>C103</td>
<td>S</td>
</tr>
<tr>
<th>12</th>
<td>13</td>
<td>0</td>
<td>3</td>
<td>Saundercock, Mr. William Henry</td>
<td>male</td>
<td>20.0</td>
<td>0</td>
<td>0</td>
<td>A/5. 2151</td>
<td>8.0500</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>13</th>
<td>14</td>
<td>0</td>
<td>3</td>
<td>Andersson, Mr. Anders Johan</td>
<td>male</td>
<td>39.0</td>
<td>1</td>
<td>5</td>
<td>347082</td>
<td>31.2750</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>14</th>
<td>15</td>
<td>0</td>
<td>3</td>
<td>Vestrom, Miss. Hulda Amanda Adolfina</td>
<td>female</td>
<td>14.0</td>
<td>0</td>
<td>0</td>
<td>350406</td>
<td>7.8542</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>15</th>
<td>16</td>
<td>1</td>
<td>2</td>
<td>Hewlett, Mrs. (Mary D Kingcome)</td>
<td>female</td>
<td>55.0</td>
<td>0</td>
<td>0</td>
<td>248706</td>
<td>16.0000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>16</th>
<td>17</td>
<td>0</td>
<td>3</td>
<td>Rice, Master. Eugene</td>
<td>male</td>
<td>2.0</td>
<td>4</td>
<td>1</td>
<td>382652</td>
<td>29.1250</td>
<td>NaN</td>
<td>Q</td>
</tr>
<tr>
<th>17</th>
<td>18</td>
<td>1</td>
<td>2</td>
<td>Williams, Mr. Charles Eugene</td>
<td>male</td>
<td>29.0</td>
<td>0</td>
<td>0</td>
<td>244373</td>
<td>13.0000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>18</th>
<td>19</td>
<td>0</td>
<td>3</td>
<td>Vander Planke, Mrs. Julius (Emelia Maria Vande...</td>
<td>female</td>
<td>31.0</td>
<td>1</td>
<td>0</td>
<td>345763</td>
<td>18.0000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>19</th>
<td>20</td>
<td>1</td>
<td>3</td>
<td>Masselmani, Mrs. Fatima</td>
<td>female</td>
<td>29.0</td>
<td>0</td>
<td>0</td>
<td>2649</td>
<td>7.2250</td>
<td>NaN</td>
<td>C</td>
</tr>
<tr>
<th>20</th>
<td>21</td>
<td>0</td>
<td>2</td>
<td>Fynney, Mr. Joseph J</td>
<td>male</td>
<td>35.0</td>
<td>0</td>
<td>0</td>
<td>239865</td>
<td>26.0000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>21</th>
<td>22</td>
<td>1</td>
<td>2</td>
<td>Beesley, Mr. Lawrence</td>
<td>male</td>
<td>34.0</td>
<td>0</td>
<td>0</td>
<td>248698</td>
<td>13.0000</td>
<td>D56</td>
<td>S</td>
</tr>
<tr>
<th>22</th>
<td>23</td>
<td>1</td>
<td>3</td>
<td>McGowan, Miss. Anna "Annie"</td>
<td>female</td>
<td>15.0</td>
<td>0</td>
<td>0</td>
<td>330923</td>
<td>8.0292</td>
<td>NaN</td>
<td>Q</td>
</tr>
<tr>
<th>23</th>
<td>24</td>
<td>1</td>
<td>1</td>
<td>Sloper, Mr. William Thompson</td>
<td>male</td>
<td>28.0</td>
<td>0</td>
<td>0</td>
<td>113788</td>
<td>35.5000</td>
<td>A6</td>
<td>S</td>
</tr>
<tr>
<th>24</th>
<td>25</td>
<td>0</td>
<td>3</td>
<td>Palsson, Miss. Torborg Danira</td>
<td>female</td>
<td>8.0</td>
<td>3</td>
<td>1</td>
<td>349909</td>
<td>21.0750</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>25</th>
<td>26</td>
<td>1</td>
<td>3</td>
<td>Asplund, Mrs. Carl Oscar (Selma Augusta Emilia...</td>
<td>female</td>
<td>38.0</td>
<td>1</td>
<td>5</td>
<td>347077</td>
<td>31.3875</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>26</th>
<td>27</td>
<td>0</td>
<td>3</td>
<td>Emir, Mr. Farred Chehab</td>
<td>male</td>
<td>29.0</td>
<td>0</td>
<td>0</td>
<td>2631</td>
<td>7.2250</td>
<td>NaN</td>
<td>C</td>
</tr>
<tr>
<th>27</th>
<td>28</td>
<td>0</td>
<td>1</td>
<td>Fortune, Mr. Charles Alexander</td>
<td>male</td>
<td>19.0</td>
<td>3</td>
<td>2</td>
<td>19950</td>
<td>263.0000</td>
<td>C23 C25 C27</td>
<td>S</td>
</tr>
<tr>
<th>28</th>
<td>29</td>
<td>1</td>
<td>3</td>
<td>O'Dwyer, Miss. Ellen "Nellie"</td>
<td>female</td>
<td>29.0</td>
<td>0</td>
<td>0</td>
<td>330959</td>
<td>7.8792</td>
<td>NaN</td>
<td>Q</td>
</tr>
<tr>
<th>29</th>
<td>30</td>
<td>0</td>
<td>3</td>
<td>Todoroff, Mr. Lalio</td>
<td>male</td>
<td>29.0</td>
<td>0</td>
<td>0</td>
<td>349216</td>
<td>7.8958</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>...</th>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
<tr>
<th>861</th>
<td>862</td>
<td>0</td>
<td>2</td>
<td>Giles, Mr. Frederick Edward</td>
<td>male</td>
<td>21.0</td>
<td>1</td>
<td>0</td>
<td>28134</td>
<td>11.5000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>862</th>
<td>863</td>
<td>1</td>
<td>1</td>
<td>Swift, Mrs. Frederick Joel (Margaret Welles Ba...</td>
<td>female</td>
<td>48.0</td>
<td>0</td>
<td>0</td>
<td>17466</td>
<td>25.9292</td>
<td>D17</td>
<td>S</td>
</tr>
<tr>
<th>863</th>
<td>864</td>
<td>0</td>
<td>3</td>
<td>Sage, Miss. Dorothy Edith "Dolly"</td>
<td>female</td>
<td>29.0</td>
<td>8</td>
<td>2</td>
<td>CA. 2343</td>
<td>69.5500</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>864</th>
<td>865</td>
<td>0</td>
<td>2</td>
<td>Gill, Mr. John William</td>
<td>male</td>
<td>24.0</td>
<td>0</td>
<td>0</td>
<td>233866</td>
<td>13.0000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>865</th>
<td>866</td>
<td>1</td>
<td>2</td>
<td>Bystrom, Mrs. (Karolina)</td>
<td>female</td>
<td>42.0</td>
<td>0</td>
<td>0</td>
<td>236852</td>
<td>13.0000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>866</th>
<td>867</td>
<td>1</td>
<td>2</td>
<td>Duran y More, Miss. Asuncion</td>
<td>female</td>
<td>27.0</td>
<td>1</td>
<td>0</td>
<td>SC/PARIS 2149</td>
<td>13.8583</td>
<td>NaN</td>
<td>C</td>
</tr>
<tr>
<th>867</th>
<td>868</td>
<td>0</td>
<td>1</td>
<td>Roebling, Mr. Washington Augustus II</td>
<td>male</td>
<td>31.0</td>
<td>0</td>
<td>0</td>
<td>PC 17590</td>
<td>50.4958</td>
<td>A24</td>
<td>S</td>
</tr>
<tr>
<th>868</th>
<td>869</td>
<td>0</td>
<td>3</td>
<td>van Melkebeke, Mr. Philemon</td>
<td>male</td>
<td>29.0</td>
<td>0</td>
<td>0</td>
<td>345777</td>
<td>9.5000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>869</th>
<td>870</td>
<td>1</td>
<td>3</td>
<td>Johnson, Master. Harold Theodor</td>
<td>male</td>
<td>4.0</td>
<td>1</td>
<td>1</td>
<td>347742</td>
<td>11.1333</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>870</th>
<td>871</td>
<td>0</td>
<td>3</td>
<td>Balkic, Mr. Cerin</td>
<td>male</td>
<td>26.0</td>
<td>0</td>
<td>0</td>
<td>349248</td>
<td>7.8958</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>871</th>
<td>872</td>
<td>1</td>
<td>1</td>
<td>Beckwith, Mrs. Richard Leonard (Sallie Monypeny)</td>
<td>female</td>
<td>47.0</td>
<td>1</td>
<td>1</td>
<td>11751</td>
<td>52.5542</td>
<td>D35</td>
<td>S</td>
</tr>
<tr>
<th>872</th>
<td>873</td>
<td>0</td>
<td>1</td>
<td>Carlsson, Mr. Frans Olof</td>
<td>male</td>
<td>33.0</td>
<td>0</td>
<td>0</td>
<td>695</td>
<td>5.0000</td>
<td>B51 B53 B55</td>
<td>S</td>
</tr>
<tr>
<th>873</th>
<td>874</td>
<td>0</td>
<td>3</td>
<td>Vander Cruyssen, Mr. Victor</td>
<td>male</td>
<td>47.0</td>
<td>0</td>
<td>0</td>
<td>345765</td>
<td>9.0000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>874</th>
<td>875</td>
<td>1</td>
<td>2</td>
<td>Abelson, Mrs. Samuel (Hannah Wizosky)</td>
<td>female</td>
<td>28.0</td>
<td>1</td>
<td>0</td>
<td>P/PP 3381</td>
<td>24.0000</td>
<td>NaN</td>
<td>C</td>
</tr>
<tr>
<th>875</th>
<td>876</td>
<td>1</td>
<td>3</td>
<td>Najib, Miss. Adele Kiamie "Jane"</td>
<td>female</td>
<td>15.0</td>
<td>0</td>
<td>0</td>
<td>2667</td>
<td>7.2250</td>
<td>NaN</td>
<td>C</td>
</tr>
<tr>
<th>876</th>
<td>877</td>
<td>0</td>
<td>3</td>
<td>Gustafsson, Mr. Alfred Ossian</td>
<td>male</td>
<td>20.0</td>
<td>0</td>
<td>0</td>
<td>7534</td>
<td>9.8458</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>877</th>
<td>878</td>
<td>0</td>
<td>3</td>
<td>Petroff, Mr. Nedelio</td>
<td>male</td>
<td>19.0</td>
<td>0</td>
<td>0</td>
<td>349212</td>
<td>7.8958</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>878</th>
<td>879</td>
<td>0</td>
<td>3</td>
<td>Laleff, Mr. Kristo</td>
<td>male</td>
<td>29.0</td>
<td>0</td>
<td>0</td>
<td>349217</td>
<td>7.8958</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>879</th>
<td>880</td>
<td>1</td>
<td>1</td>
<td>Potter, Mrs. Thomas Jr (Lily Alexenia Wilson)</td>
<td>female</td>
<td>56.0</td>
<td>0</td>
<td>1</td>
<td>11767</td>
<td>83.1583</td>
<td>C50</td>
<td>C</td>
</tr>
<tr>
<th>880</th>
<td>881</td>
<td>1</td>
<td>2</td>
<td>Shelley, Mrs. William (Imanita Parrish Hall)</td>
<td>female</td>
<td>25.0</td>
<td>0</td>
<td>1</td>
<td>230433</td>
<td>26.0000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>881</th>
<td>882</td>
<td>0</td>
<td>3</td>
<td>Markun, Mr. Johann</td>
<td>male</td>
<td>33.0</td>
<td>0</td>
<td>0</td>
<td>349257</td>
<td>7.8958</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>882</th>
<td>883</td>
<td>0</td>
<td>3</td>
<td>Dahlberg, Miss. Gerda Ulrika</td>
<td>female</td>
<td>22.0</td>
<td>0</td>
<td>0</td>
<td>7552</td>
<td>10.5167</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>883</th>
<td>884</td>
<td>0</td>
<td>2</td>
<td>Banfield, Mr. Frederick James</td>
<td>male</td>
<td>28.0</td>
<td>0</td>
<td>0</td>
<td>C.A./SOTON 34068</td>
<td>10.5000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>884</th>
<td>885</td>
<td>0</td>
<td>3</td>
<td>Sutehall, Mr. Henry Jr</td>
<td>male</td>
<td>25.0</td>
<td>0</td>
<td>0</td>
<td>SOTON/OQ 392076</td>
<td>7.0500</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>885</th>
<td>886</td>
<td>0</td>
<td>3</td>
<td>Rice, Mrs. William (Margaret Norton)</td>
<td>female</td>
<td>39.0</td>
<td>0</td>
<td>5</td>
<td>382652</td>
<td>29.1250</td>
<td>NaN</td>
<td>Q</td>
</tr>
<tr>
<th>886</th>
<td>887</td>
<td>0</td>
<td>2</td>
<td>Montvila, Rev. Juozas</td>
<td>male</td>
<td>27.0</td>
<td>0</td>
<td>0</td>
<td>211536</td>
<td>13.0000</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>887</th>
<td>888</td>
<td>1</td>
<td>1</td>
<td>Graham, Miss. Margaret Edith</td>
<td>female</td>
<td>19.0</td>
<td>0</td>
<td>0</td>
<td>112053</td>
<td>30.0000</td>
<td>B42</td>
<td>S</td>
</tr>
<tr>
<th>888</th>
<td>889</td>
<td>0</td>
<td>3</td>
<td>Johnston, Miss. Catherine Helen "Carrie"</td>
<td>female</td>
<td>29.0</td>
<td>1</td>
<td>2</td>
<td>W./C. 6607</td>
<td>23.4500</td>
<td>NaN</td>
<td>S</td>
</tr>
<tr>
<th>889</th>
<td>890</td>
<td>1</td>
<td>1</td>
<td>Behr, Mr. Karl Howell</td>
<td>male</td>
<td>26.0</td>
<td>0</td>
<td>0</td>
<td>111369</td>
<td>30.0000</td>
<td>C148</td>
<td>C</td>
</tr>
<tr>
<th>890</th>
<td>891</td>
<td>0</td>
<td>3</td>
<td>Dooley, Mr. Patrick</td>
<td>male</td>
<td>32.0</td>
<td>0</td>
<td>0</td>
<td>370376</td>
<td>7.7500</td>
<td>NaN</td>
<td>Q</td>
</tr>
</tbody>
</table>
<p>891 rows × 12 columns</p>
</div>
</div>
</div>
</div>
</div>
### More Complex Models - Data Imputation
- Could be that Age could be inferred from other variables, such as SibSp, Name, Fare, etc.
- A next step could be to build a more complex regression or tree model that would involve data tat was not null.
### Missing Data - Class Values
- We have 2 missing data values for the Embarked Class
- What should we replace them as?
<div markdown="1" class="cell code_cell">
<div class="input_area" markdown="1">
```pd.value_counts(train.Embarked)
Copyright AnalyticsDojo 2016. This work is licensed under the Creative Commons Attribution 4.0 International license agreement. Adopted from materials Copyright Steve Phelps 2014