|
20 | 20 | "### Step 1. Import the necessary libraries" |
21 | 21 | ] |
22 | 22 | }, |
23 | | - { |
24 | | - "cell_type": "code", |
25 | | - "execution_count": 1, |
26 | | - "metadata": { |
27 | | - "collapsed": false |
28 | | - }, |
29 | | - "outputs": [], |
30 | | - "source": [ |
31 | | - "import pandas as pd\n", |
32 | | - "import matplotlib.pyplot as plt\n", |
33 | | - "import seaborn as sbn\n", |
34 | | - "\n", |
35 | | - "%matplotlib inline" |
36 | | - ] |
37 | | - }, |
38 | | - { |
39 | | - "cell_type": "markdown", |
40 | | - "metadata": {}, |
41 | | - "source": [ |
42 | | - "### Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/Visualization/Titanic%20Desaster/train.csv). " |
43 | | - ] |
44 | | - }, |
45 | | - { |
46 | | - "cell_type": "markdown", |
47 | | - "metadata": {}, |
48 | | - "source": [ |
49 | | - "### Step 3. Assign it to a variable titanic " |
50 | | - ] |
51 | | - }, |
52 | | - { |
53 | | - "cell_type": "code", |
54 | | - "execution_count": 3, |
55 | | - "metadata": { |
56 | | - "collapsed": false |
57 | | - }, |
58 | | - "outputs": [ |
59 | | - { |
60 | | - "data": { |
61 | | - "text/html": [ |
62 | | - "<div>\n", |
63 | | - "<table border=\"1\" class=\"dataframe\">\n", |
64 | | - " <thead>\n", |
65 | | - " <tr style=\"text-align: right;\">\n", |
66 | | - " <th></th>\n", |
67 | | - " <th>PassengerId</th>\n", |
68 | | - " <th>Survived</th>\n", |
69 | | - " <th>Pclass</th>\n", |
70 | | - " <th>Name</th>\n", |
71 | | - " <th>Sex</th>\n", |
72 | | - " <th>Age</th>\n", |
73 | | - " <th>SibSp</th>\n", |
74 | | - " <th>Parch</th>\n", |
75 | | - " <th>Ticket</th>\n", |
76 | | - " <th>Fare</th>\n", |
77 | | - " <th>Cabin</th>\n", |
78 | | - " <th>Embarked</th>\n", |
79 | | - " </tr>\n", |
80 | | - " </thead>\n", |
81 | | - " <tbody>\n", |
82 | | - " <tr>\n", |
83 | | - " <th>0</th>\n", |
84 | | - " <td>1</td>\n", |
85 | | - " <td>0</td>\n", |
86 | | - " <td>3</td>\n", |
87 | | - " <td>Braund, Mr. Owen Harris</td>\n", |
88 | | - " <td>male</td>\n", |
89 | | - " <td>22.0</td>\n", |
90 | | - " <td>1</td>\n", |
91 | | - " <td>0</td>\n", |
92 | | - " <td>A/5 21171</td>\n", |
93 | | - " <td>7.2500</td>\n", |
94 | | - " <td>NaN</td>\n", |
95 | | - " <td>S</td>\n", |
96 | | - " </tr>\n", |
97 | | - " <tr>\n", |
98 | | - " <th>1</th>\n", |
99 | | - " <td>2</td>\n", |
100 | | - " <td>1</td>\n", |
101 | | - " <td>1</td>\n", |
102 | | - " <td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>\n", |
103 | | - " <td>female</td>\n", |
104 | | - " <td>38.0</td>\n", |
105 | | - " <td>1</td>\n", |
106 | | - " <td>0</td>\n", |
107 | | - " <td>PC 17599</td>\n", |
108 | | - " <td>71.2833</td>\n", |
109 | | - " <td>C85</td>\n", |
110 | | - " <td>C</td>\n", |
111 | | - " </tr>\n", |
112 | | - " <tr>\n", |
113 | | - " <th>2</th>\n", |
114 | | - " <td>3</td>\n", |
115 | | - " <td>1</td>\n", |
116 | | - " <td>3</td>\n", |
117 | | - " <td>Heikkinen, Miss. Laina</td>\n", |
118 | | - " <td>female</td>\n", |
119 | | - " <td>26.0</td>\n", |
120 | | - " <td>0</td>\n", |
121 | | - " <td>0</td>\n", |
122 | | - " <td>STON/O2. 3101282</td>\n", |
123 | | - " <td>7.9250</td>\n", |
124 | | - " <td>NaN</td>\n", |
125 | | - " <td>S</td>\n", |
126 | | - " </tr>\n", |
127 | | - " <tr>\n", |
128 | | - " <th>3</th>\n", |
129 | | - " <td>4</td>\n", |
130 | | - " <td>1</td>\n", |
131 | | - " <td>1</td>\n", |
132 | | - " <td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>\n", |
133 | | - " <td>female</td>\n", |
134 | | - " <td>35.0</td>\n", |
135 | | - " <td>1</td>\n", |
136 | | - " <td>0</td>\n", |
137 | | - " <td>113803</td>\n", |
138 | | - " <td>53.1000</td>\n", |
139 | | - " <td>C123</td>\n", |
140 | | - " <td>S</td>\n", |
141 | | - " </tr>\n", |
142 | | - " <tr>\n", |
143 | | - " <th>4</th>\n", |
144 | | - " <td>5</td>\n", |
145 | | - " <td>0</td>\n", |
146 | | - " <td>3</td>\n", |
147 | | - " <td>Allen, Mr. William Henry</td>\n", |
148 | | - " <td>male</td>\n", |
149 | | - " <td>35.0</td>\n", |
150 | | - " <td>0</td>\n", |
151 | | - " <td>0</td>\n", |
152 | | - " <td>373450</td>\n", |
153 | | - " <td>8.0500</td>\n", |
154 | | - " <td>NaN</td>\n", |
155 | | - " <td>S</td>\n", |
156 | | - " </tr>\n", |
157 | | - " </tbody>\n", |
158 | | - "</table>\n", |
159 | | - "</div>" |
160 | | - ], |
161 | | - "text/plain": [ |
162 | | - " PassengerId Survived Pclass \\\n", |
163 | | - "0 1 0 3 \n", |
164 | | - "1 2 1 1 \n", |
165 | | - "2 3 1 3 \n", |
166 | | - "3 4 1 1 \n", |
167 | | - "4 5 0 3 \n", |
168 | | - "\n", |
169 | | - " Name Sex Age SibSp \\\n", |
170 | | - "0 Braund, Mr. Owen Harris male 22.0 1 \n", |
171 | | - "1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 1 \n", |
172 | | - "2 Heikkinen, Miss. Laina female 26.0 0 \n", |
173 | | - "3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 1 \n", |
174 | | - "4 Allen, Mr. William Henry male 35.0 0 \n", |
175 | | - "\n", |
176 | | - " Parch Ticket Fare Cabin Embarked \n", |
177 | | - "0 0 A/5 21171 7.2500 NaN S \n", |
178 | | - "1 0 PC 17599 71.2833 C85 C \n", |
179 | | - "2 0 STON/O2. 3101282 7.9250 NaN S \n", |
180 | | - "3 0 113803 53.1000 C123 S \n", |
181 | | - "4 0 373450 8.0500 NaN S " |
182 | | - ] |
183 | | - }, |
184 | | - "execution_count": 3, |
185 | | - "metadata": {}, |
186 | | - "output_type": "execute_result" |
187 | | - } |
188 | | - ], |
189 | | - "source": [ |
190 | | - "titanic = pd.read_csv('https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/Visualization/Titanic%20Desaster/train.csv')\n", |
191 | | - "\n", |
192 | | - "titanic.head()" |
193 | | - ] |
194 | | - }, |
195 | | - { |
196 | | - "cell_type": "markdown", |
197 | | - "metadata": {}, |
198 | | - "source": [ |
199 | | - "### Step 4. " |
200 | | - ] |
201 | | - }, |
202 | 23 | { |
203 | 24 | "cell_type": "code", |
204 | 25 | "execution_count": null, |
|
212 | 33 | "cell_type": "markdown", |
213 | 34 | "metadata": {}, |
214 | 35 | "source": [ |
215 | | - "### Step 5. " |
| 36 | + "### Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/Visualization/Titanic_Desaster/train.csv). " |
216 | 37 | ] |
217 | 38 | }, |
218 | | - { |
219 | | - "cell_type": "code", |
220 | | - "execution_count": null, |
221 | | - "metadata": { |
222 | | - "collapsed": false |
223 | | - }, |
224 | | - "outputs": [], |
225 | | - "source": [] |
226 | | - }, |
227 | | - { |
228 | | - "cell_type": "markdown", |
229 | | - "metadata": {}, |
230 | | - "source": [ |
231 | | - "### Step 6. " |
232 | | - ] |
233 | | - }, |
234 | | - { |
235 | | - "cell_type": "code", |
236 | | - "execution_count": null, |
237 | | - "metadata": { |
238 | | - "collapsed": true |
239 | | - }, |
240 | | - "outputs": [], |
241 | | - "source": [] |
242 | | - }, |
243 | 39 | { |
244 | 40 | "cell_type": "markdown", |
245 | 41 | "metadata": {}, |
246 | 42 | "source": [ |
247 | | - "### Step 7. " |
248 | | - ] |
249 | | - }, |
250 | | - { |
251 | | - "cell_type": "code", |
252 | | - "execution_count": null, |
253 | | - "metadata": { |
254 | | - "collapsed": false |
255 | | - }, |
256 | | - "outputs": [], |
257 | | - "source": [] |
258 | | - }, |
259 | | - { |
260 | | - "cell_type": "markdown", |
261 | | - "metadata": {}, |
262 | | - "source": [ |
263 | | - "### Step 8. " |
| 43 | + "### Step 3. Assign it to a variable titanic " |
264 | 44 | ] |
265 | 45 | }, |
266 | 46 | { |
|
276 | 56 | "cell_type": "markdown", |
277 | 57 | "metadata": {}, |
278 | 58 | "source": [ |
279 | | - "### Step 9. " |
| 59 | + "### Step 4. Set PassengerId as the index " |
280 | 60 | ] |
281 | 61 | }, |
282 | 62 | { |
|
292 | 72 | "cell_type": "markdown", |
293 | 73 | "metadata": {}, |
294 | 74 | "source": [ |
295 | | - "### Step 10. " |
| 75 | + "### Step 5. Create a pie chart presenting the male/female proportion" |
296 | 76 | ] |
297 | 77 | }, |
298 | 78 | { |
|
308 | 88 | "cell_type": "markdown", |
309 | 89 | "metadata": {}, |
310 | 90 | "source": [ |
311 | | - "### Step 11. " |
| 91 | + "### Step 6. Create a scatterplot with the Fare payed and the Age, differ the plot color by gender" |
312 | 92 | ] |
313 | 93 | }, |
314 | 94 | { |
|
324 | 104 | "cell_type": "markdown", |
325 | 105 | "metadata": {}, |
326 | 106 | "source": [ |
327 | | - "### Step 12. " |
| 107 | + "### Step 7. How many people survived?" |
328 | 108 | ] |
329 | 109 | }, |
330 | 110 | { |
|
340 | 120 | "cell_type": "markdown", |
341 | 121 | "metadata": {}, |
342 | 122 | "source": [ |
343 | | - "### Step 13. " |
| 123 | + "### Step 8. Create a histogram with the Fare payed" |
344 | 124 | ] |
345 | 125 | }, |
346 | 126 | { |
|
352 | 132 | "outputs": [], |
353 | 133 | "source": [] |
354 | 134 | }, |
355 | | - { |
356 | | - "cell_type": "markdown", |
357 | | - "metadata": {}, |
358 | | - "source": [ |
359 | | - "### Step 14. " |
360 | | - ] |
361 | | - }, |
362 | | - { |
363 | | - "cell_type": "code", |
364 | | - "execution_count": null, |
365 | | - "metadata": { |
366 | | - "collapsed": true |
367 | | - }, |
368 | | - "outputs": [], |
369 | | - "source": [] |
370 | | - }, |
371 | | - { |
372 | | - "cell_type": "markdown", |
373 | | - "metadata": {}, |
374 | | - "source": [ |
375 | | - "### Step 15. " |
376 | | - ] |
377 | | - }, |
378 | | - { |
379 | | - "cell_type": "code", |
380 | | - "execution_count": null, |
381 | | - "metadata": { |
382 | | - "collapsed": true |
383 | | - }, |
384 | | - "outputs": [], |
385 | | - "source": [] |
386 | | - }, |
387 | | - { |
388 | | - "cell_type": "markdown", |
389 | | - "metadata": {}, |
390 | | - "source": [ |
391 | | - "### Step 16. " |
392 | | - ] |
393 | | - }, |
394 | | - { |
395 | | - "cell_type": "code", |
396 | | - "execution_count": null, |
397 | | - "metadata": { |
398 | | - "collapsed": true |
399 | | - }, |
400 | | - "outputs": [], |
401 | | - "source": [] |
402 | | - }, |
403 | 135 | { |
404 | 136 | "cell_type": "markdown", |
405 | 137 | "metadata": {}, |
|
0 commit comments