{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "Playing_with_Titanic_Dataset.ipynb", "version": "0.3.2", "provenance": [], "collapsed_sections": [], "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "cell_type": "markdown", "metadata": { "id": "hD3dcw0JdAot", "colab_type": "text" }, "source": [ "\n", "
\n", "\n", "
\n", "\n", "**This mini project or whatever you call it as was done with the help of the website down below, which helped me in understanding, analysing the data by scraping the data from the internet.**\n", "\n", "\n", "---\n", "\n", "\n", "[Getting started with Data Analysis with Python Pandas](https://towardsdatascience.com/getting-started-to-data-analysis-with-python-pandas-with-titanic-dataset-a195ab043c77\n", ")\n", "\n", "---\n", "\n", "More importantly the \"Titanic\" dataset was retrived from Kaggle and the link can be found below:\n", "\n", "[Titanic Dataset](https://www.kaggle.com/c/titanic/data)\n", "\n", "\n", "\n", "---\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "qI3t3D-UqxZo", "colab_type": "text" }, "source": [ "The following two lines of code must be entered in order to upload the file from the local drive, because google colab stores everything in your drive. So make sure that you that you read the article down below before you begin typing the code. Moreover, I dont want you guys to stuck and watch the screen when you get an error.\n", "\n", "[Click Here](https://towardsdatascience.com/3-ways-to-load-csv-files-into-colab-7c14fcbdcb92)" ] }, { "cell_type": "code", "metadata": { "id": "YM_Dq2ZAlaA2", "colab_type": "code", "outputId": "3e580035-651c-46fa-b1e1-1e81222dadf6", "colab": { "resources": { "http://localhost:8080/nbextensions/google.colab/files.js": { "data": "Ly8gQ29weXJpZ2h0IDIwMTcgR29vZ2xlIExMQwovLwovLyBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLy8geW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxp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gICAgICAgZmlsZTogZmlsZS5uYW1lLAogICAgICAgICAgZGF0YTogYmFzZTY0LAogICAgICAgIH0sCiAgICAgIH07CiAgICAgIHBlcmNlbnQudGV4dENvbnRlbnQgPQogICAgICAgICAgYCR7TWF0aC5yb3VuZCgocG9zaXRpb24gLyBmaWxlRGF0YS5ieXRlTGVuZ3RoKSAqIDEwMCl9JSBkb25lYDsKICAgIH0KICB9CgogIC8vIEFsbCBkb25lLgogIHlpZWxkIHsKICAgIHJlc3BvbnNlOiB7CiAgICAgIGFjdGlvbjogJ2NvbXBsZXRlJywKICAgIH0KICB9Owp9CgpzY29wZS5nb29nbGUgPSBzY29wZS5nb29nbGUgfHwge307CnNjb3BlLmdvb2dsZS5jb2xhYiA9IHNjb3BlLmdvb2dsZS5jb2xhYiB8fCB7fTsKc2NvcGUuZ29vZ2xlLmNvbGFiLl9maWxlcyA9IHsKICBfdXBsb2FkRmlsZXMsCiAgX3VwbG9hZEZpbGVzQ29udGludWUsCn07Cn0pKHNlbGYpOwo=", "ok": true, "headers": [ [ "content-type", "application/javascript" ] ], "status": 200, "status_text": "" } }, "base_uri": "https://localhost:8080/", "height": 75 } }, "source": [ "from google.colab import files\n", "uploaded = files.upload()" ], "execution_count": 3, "outputs": [ { "output_type": "display_data", "data": { "text/html": [ "\n", " \n", " \n", " Upload widget is only available when the cell has been executed in the\n", " current browser session. Please rerun this cell to enable.\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": { "tags": [] } }, { "output_type": "stream", "text": [ "Saving train.csv to train.csv\n" ], "name": "stdout" } ] }, { "cell_type": "markdown", "metadata": { "id": "CsdIJ9lAsS6G", "colab_type": "text" }, "source": [ "\n", "After entering the above two lines of code, wait till you get the 100% uploaded confirmation. Finally once you get that, please enter the two more lines (I really don't know what the two line does)\n", "\n" ] }, { "cell_type": "code", "metadata": { "id": "71vMqOu7ljTo", "colab_type": "code", "colab": {} }, "source": [ "import io\n", "df2 = pd.read_csv(io.BytesIO(uploaded['train.csv']))" ], "execution_count": 0, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "MjBBMJ-wRKpZ", "colab_type": "text" }, "source": [ "# Importing the dataset with read_csv and displaying the data.\n" ] }, { "cell_type": "code", "metadata": { "id": "ORH0fyc7Wlh9", "colab_type": "code", "outputId": "1c9048e7-f669-4b7f-8914-b940f1cad169", "colab": { "base_uri": "https://localhost:8080/", "height": 2157 } }, "source": [ "import pandas as pd\n", "import csv\n", "import matplotlib.pyplot as plt\n", "\n", "df = pd.read_csv(\"train.csv\")\n", "df" ], "execution_count": 7, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAgeSibSpParchTicketFareCabinEmbarked
0103Braund, Mr. Owen Harrismale22.010A/5 211717.2500NaNS
1211Cumings, Mrs. John Bradley (Florence Briggs Th...female38.010PC 1759971.2833C85C
2313Heikkinen, Miss. Lainafemale26.000STON/O2. 31012827.9250NaNS
3411Futrelle, Mrs. Jacques Heath (Lily May Peel)female35.01011380353.1000C123S
4503Allen, Mr. William Henrymale35.0003734508.0500NaNS
5603Moran, Mr. JamesmaleNaN003308778.4583NaNQ
6701McCarthy, Mr. Timothy Jmale54.0001746351.8625E46S
7803Palsson, Master. Gosta Leonardmale2.03134990921.0750NaNS
8913Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg)female27.00234774211.1333NaNS
91012Nasser, Mrs. Nicholas (Adele Achem)female14.01023773630.0708NaNC
101113Sandstrom, Miss. Marguerite Rutfemale4.011PP 954916.7000G6S
111211Bonnell, Miss. Elizabethfemale58.00011378326.5500C103S
121303Saundercock, Mr. William Henrymale20.000A/5. 21518.0500NaNS
131403Andersson, Mr. Anders Johanmale39.01534708231.2750NaNS
141503Vestrom, Miss. Hulda Amanda Adolfinafemale14.0003504067.8542NaNS
151612Hewlett, Mrs. (Mary D Kingcome)female55.00024870616.0000NaNS
161703Rice, Master. Eugenemale2.04138265229.1250NaNQ
171812Williams, Mr. Charles EugenemaleNaN0024437313.0000NaNS
181903Vander Planke, Mrs. Julius (Emelia Maria Vande...female31.01034576318.0000NaNS
192013Masselmani, Mrs. FatimafemaleNaN0026497.2250NaNC
202102Fynney, Mr. Joseph Jmale35.00023986526.0000NaNS
212212Beesley, Mr. Lawrencemale34.00024869813.0000D56S
222313McGowan, Miss. Anna \"Annie\"female15.0003309238.0292NaNQ
232411Sloper, Mr. William Thompsonmale28.00011378835.5000A6S
242503Palsson, Miss. Torborg Danirafemale8.03134990921.0750NaNS
252613Asplund, Mrs. Carl Oscar (Selma Augusta Emilia...female38.01534707731.3875NaNS
262703Emir, Mr. Farred ChehabmaleNaN0026317.2250NaNC
272801Fortune, Mr. Charles Alexandermale19.03219950263.0000C23 C25 C27S
282913O'Dwyer, Miss. Ellen \"Nellie\"femaleNaN003309597.8792NaNQ
293003Todoroff, Mr. LaliomaleNaN003492167.8958NaNS
.......................................
86186202Giles, Mr. Frederick Edwardmale21.0102813411.5000NaNS
86286311Swift, Mrs. Frederick Joel (Margaret Welles Ba...female48.0001746625.9292D17S
86386403Sage, Miss. Dorothy Edith \"Dolly\"femaleNaN82CA. 234369.5500NaNS
86486502Gill, Mr. John Williammale24.00023386613.0000NaNS
86586612Bystrom, Mrs. (Karolina)female42.00023685213.0000NaNS
86686712Duran y More, Miss. Asuncionfemale27.010SC/PARIS 214913.8583NaNC
86786801Roebling, Mr. Washington Augustus IImale31.000PC 1759050.4958A24S
86886903van Melkebeke, Mr. PhilemonmaleNaN003457779.5000NaNS
86987013Johnson, Master. Harold Theodormale4.01134774211.1333NaNS
87087103Balkic, Mr. Cerinmale26.0003492487.8958NaNS
87187211Beckwith, Mrs. Richard Leonard (Sallie Monypeny)female47.0111175152.5542D35S
87287301Carlsson, Mr. Frans Olofmale33.0006955.0000B51 B53 B55S
87387403Vander Cruyssen, Mr. Victormale47.0003457659.0000NaNS
87487512Abelson, Mrs. Samuel (Hannah Wizosky)female28.010P/PP 338124.0000NaNC
87587613Najib, Miss. Adele Kiamie \"Jane\"female15.00026677.2250NaNC
87687703Gustafsson, Mr. Alfred Ossianmale20.00075349.8458NaNS
87787803Petroff, Mr. Nedeliomale19.0003492127.8958NaNS
87887903Laleff, Mr. KristomaleNaN003492177.8958NaNS
87988011Potter, Mrs. Thomas Jr (Lily Alexenia Wilson)female56.0011176783.1583C50C
88088112Shelley, Mrs. William (Imanita Parrish Hall)female25.00123043326.0000NaNS
88188203Markun, Mr. Johannmale33.0003492577.8958NaNS
88288303Dahlberg, Miss. Gerda Ulrikafemale22.000755210.5167NaNS
88388402Banfield, Mr. Frederick Jamesmale28.000C.A./SOTON 3406810.5000NaNS
88488503Sutehall, Mr. Henry Jrmale25.000SOTON/OQ 3920767.0500NaNS
88588603Rice, Mrs. William (Margaret Norton)female39.00538265229.1250NaNQ
88688702Montvila, Rev. Juozasmale27.00021153613.0000NaNS
88788811Graham, Miss. Margaret Edithfemale19.00011205330.0000B42S
88888903Johnston, Miss. Catherine Helen \"Carrie\"femaleNaN12W./C. 660723.4500NaNS
88989011Behr, Mr. Karl Howellmale26.00011136930.0000C148C
89089103Dooley, Mr. Patrickmale32.0003703767.7500NaNQ
\n", "

891 rows × 12 columns

\n", "
" ], "text/plain": [ " PassengerId Survived Pclass ... Fare Cabin Embarked\n", "0 1 0 3 ... 7.2500 NaN S\n", "1 2 1 1 ... 71.2833 C85 C\n", "2 3 1 3 ... 7.9250 NaN S\n", "3 4 1 1 ... 53.1000 C123 S\n", "4 5 0 3 ... 8.0500 NaN S\n", "5 6 0 3 ... 8.4583 NaN Q\n", "6 7 0 1 ... 51.8625 E46 S\n", "7 8 0 3 ... 21.0750 NaN S\n", "8 9 1 3 ... 11.1333 NaN S\n", "9 10 1 2 ... 30.0708 NaN C\n", "10 11 1 3 ... 16.7000 G6 S\n", "11 12 1 1 ... 26.5500 C103 S\n", "12 13 0 3 ... 8.0500 NaN S\n", "13 14 0 3 ... 31.2750 NaN S\n", "14 15 0 3 ... 7.8542 NaN S\n", "15 16 1 2 ... 16.0000 NaN S\n", "16 17 0 3 ... 29.1250 NaN Q\n", "17 18 1 2 ... 13.0000 NaN S\n", "18 19 0 3 ... 18.0000 NaN S\n", "19 20 1 3 ... 7.2250 NaN C\n", "20 21 0 2 ... 26.0000 NaN S\n", "21 22 1 2 ... 13.0000 D56 S\n", "22 23 1 3 ... 8.0292 NaN Q\n", "23 24 1 1 ... 35.5000 A6 S\n", "24 25 0 3 ... 21.0750 NaN S\n", "25 26 1 3 ... 31.3875 NaN S\n", "26 27 0 3 ... 7.2250 NaN C\n", "27 28 0 1 ... 263.0000 C23 C25 C27 S\n", "28 29 1 3 ... 7.8792 NaN Q\n", "29 30 0 3 ... 7.8958 NaN S\n", ".. ... ... ... ... ... ... ...\n", "861 862 0 2 ... 11.5000 NaN S\n", "862 863 1 1 ... 25.9292 D17 S\n", "863 864 0 3 ... 69.5500 NaN S\n", "864 865 0 2 ... 13.0000 NaN S\n", "865 866 1 2 ... 13.0000 NaN S\n", "866 867 1 2 ... 13.8583 NaN C\n", "867 868 0 1 ... 50.4958 A24 S\n", "868 869 0 3 ... 9.5000 NaN S\n", "869 870 1 3 ... 11.1333 NaN S\n", "870 871 0 3 ... 7.8958 NaN S\n", "871 872 1 1 ... 52.5542 D35 S\n", "872 873 0 1 ... 5.0000 B51 B53 B55 S\n", "873 874 0 3 ... 9.0000 NaN S\n", "874 875 1 2 ... 24.0000 NaN C\n", "875 876 1 3 ... 7.2250 NaN C\n", "876 877 0 3 ... 9.8458 NaN S\n", "877 878 0 3 ... 7.8958 NaN S\n", "878 879 0 3 ... 7.8958 NaN S\n", "879 880 1 1 ... 83.1583 C50 C\n", "880 881 1 2 ... 26.0000 NaN S\n", "881 882 0 3 ... 7.8958 NaN S\n", "882 883 0 3 ... 10.5167 NaN S\n", "883 884 0 2 ... 10.5000 NaN S\n", "884 885 0 3 ... 7.0500 NaN S\n", "885 886 0 3 ... 29.1250 NaN Q\n", "886 887 0 2 ... 13.0000 NaN S\n", "887 888 1 1 ... 30.0000 B42 S\n", "888 889 0 3 ... 23.4500 NaN S\n", "889 890 1 1 ... 30.0000 C148 C\n", "890 891 0 3 ... 7.7500 NaN Q\n", "\n", "[891 rows x 12 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 7 } ] }, { "cell_type": "markdown", "metadata": { "id": "Mr_mxZgnQ2uQ", "colab_type": "text" }, "source": [ "# **Using Head and Tail methods inorder to display the data.**" ] }, { "cell_type": "code", "metadata": { "id": "6GO30V6Sczk3", "colab_type": "code", "outputId": "58072394-e095-40d0-f5ae-06762aeb3560", "colab": { "base_uri": "https://localhost:8080/", "height": 202 } }, "source": [ "df.head(5) # Used to display top 5" ], "execution_count": 8, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAgeSibSpParchTicketFareCabinEmbarked
0103Braund, Mr. Owen Harrismale22.010A/5 211717.2500NaNS
1211Cumings, Mrs. John Bradley (Florence Briggs Th...female38.010PC 1759971.2833C85C
2313Heikkinen, Miss. Lainafemale26.000STON/O2. 31012827.9250NaNS
3411Futrelle, Mrs. Jacques Heath (Lily May Peel)female35.01011380353.1000C123S
4503Allen, Mr. William Henrymale35.0003734508.0500NaNS
\n", "
" ], "text/plain": [ " PassengerId Survived Pclass ... Fare Cabin Embarked\n", "0 1 0 3 ... 7.2500 NaN S\n", "1 2 1 1 ... 71.2833 C85 C\n", "2 3 1 3 ... 7.9250 NaN S\n", "3 4 1 1 ... 53.1000 C123 S\n", "4 5 0 3 ... 8.0500 NaN S\n", "\n", "[5 rows x 12 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 8 } ] }, { "cell_type": "code", "metadata": { "id": "zcxr2dnFhT5h", "colab_type": "code", "outputId": "f1006878-059b-4082-f2f8-9c3637c8e972", "colab": { "base_uri": "https://localhost:8080/", "height": 202 } }, "source": [ "df.tail(5) # Used to display last 5" ], "execution_count": 9, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAgeSibSpParchTicketFareCabinEmbarked
88688702Montvila, Rev. Juozasmale27.00021153613.00NaNS
88788811Graham, Miss. Margaret Edithfemale19.00011205330.00B42S
88888903Johnston, Miss. Catherine Helen \"Carrie\"femaleNaN12W./C. 660723.45NaNS
88989011Behr, Mr. Karl Howellmale26.00011136930.00C148C
89089103Dooley, Mr. Patrickmale32.0003703767.75NaNQ
\n", "
" ], "text/plain": [ " PassengerId Survived Pclass ... Fare Cabin Embarked\n", "886 887 0 2 ... 13.00 NaN S\n", "887 888 1 1 ... 30.00 B42 S\n", "888 889 0 3 ... 23.45 NaN S\n", "889 890 1 1 ... 30.00 C148 C\n", "890 891 0 3 ... 7.75 NaN Q\n", "\n", "[5 rows x 12 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 9 } ] }, { "cell_type": "markdown", "metadata": { "id": "Tw84bFRrRUNJ", "colab_type": "text" }, "source": [ "# Accessing specific coloums which are needed." ] }, { "cell_type": "code", "metadata": { "id": "wER50sYvhVPB", "colab_type": "code", "outputId": "82e28537-4784-4607-8042-c00a7c635898", "colab": { "base_uri": "https://localhost:8080/", "height": 202 } }, "source": [ "df = pd.read_csv(\"train.csv\", usecols= [\"PassengerId\", \"Survived\", \"Pclass\", \"Name\", \"Sex\",\"Age\"])\n", "df.head()" ], "execution_count": 10, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAge
0103Braund, Mr. Owen Harrismale22.0
1211Cumings, Mrs. John Bradley (Florence Briggs Th...female38.0
2313Heikkinen, Miss. Lainafemale26.0
3411Futrelle, Mrs. Jacques Heath (Lily May Peel)female35.0
4503Allen, Mr. William Henrymale35.0
\n", "
" ], "text/plain": [ " PassengerId Survived ... Sex Age\n", "0 1 0 ... male 22.0\n", "1 2 1 ... female 38.0\n", "2 3 1 ... female 26.0\n", "3 4 1 ... female 35.0\n", "4 5 0 ... male 35.0\n", "\n", "[5 rows x 6 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 10 } ] }, { "cell_type": "markdown", "metadata": { "id": "fsNH60Q6RhCL", "colab_type": "text" }, "source": [ "# Get more information about the database by using describe method." ] }, { "cell_type": "code", "metadata": { "id": "Qb4YdAa_hozX", "colab_type": "code", "outputId": "6c83d200-eadc-48fd-97d4-1ca966b75048", "colab": { "base_uri": "https://localhost:8080/", "height": 294 } }, "source": [ "df.describe()" ], "execution_count": 11, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassAge
count891.000000891.000000891.000000714.000000
mean446.0000000.3838382.30864229.699118
std257.3538420.4865920.83607114.526497
min1.0000000.0000001.0000000.420000
25%223.5000000.0000002.00000020.125000
50%446.0000000.0000003.00000028.000000
75%668.5000001.0000003.00000038.000000
max891.0000001.0000003.00000080.000000
\n", "
" ], "text/plain": [ " PassengerId Survived Pclass Age\n", "count 891.000000 891.000000 891.000000 714.000000\n", "mean 446.000000 0.383838 2.308642 29.699118\n", "std 257.353842 0.486592 0.836071 14.526497\n", "min 1.000000 0.000000 1.000000 0.420000\n", "25% 223.500000 0.000000 2.000000 20.125000\n", "50% 446.000000 0.000000 3.000000 28.000000\n", "75% 668.500000 1.000000 3.000000 38.000000\n", "max 891.000000 1.000000 3.000000 80.000000" ] }, "metadata": { "tags": [] }, "execution_count": 11 } ] }, { "cell_type": "markdown", "metadata": { "id": "ORyXDmoyRtAK", "colab_type": "text" }, "source": [ "# Sorting the values by using the sort method." ] }, { "cell_type": "code", "metadata": { "id": "EZ5V3Zmvh1Ef", "colab_type": "code", "outputId": "9c059e6b-dcb3-4892-b627-b8423584c0d6", "colab": { "base_uri": "https://localhost:8080/", "height": 202 } }, "source": [ "df.sort_values(\"Age\")\n", "df.head()" ], "execution_count": 12, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAge
0103Braund, Mr. Owen Harrismale22.0
1211Cumings, Mrs. John Bradley (Florence Briggs Th...female38.0
2313Heikkinen, Miss. Lainafemale26.0
3411Futrelle, Mrs. Jacques Heath (Lily May Peel)female35.0
4503Allen, Mr. William Henrymale35.0
\n", "
" ], "text/plain": [ " PassengerId Survived ... Sex Age\n", "0 1 0 ... male 22.0\n", "1 2 1 ... female 38.0\n", "2 3 1 ... female 26.0\n", "3 4 1 ... female 35.0\n", "4 5 0 ... male 35.0\n", "\n", "[5 rows x 6 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 12 } ] }, { "cell_type": "markdown", "metadata": { "id": "6-XFGEpdR1fW", "colab_type": "text" }, "source": [ "# Sorting the values according to the age." ] }, { "cell_type": "code", "metadata": { "id": "trrCNJzLiNwa", "colab_type": "code", "outputId": "15246d4a-a17c-40aa-b74c-979d8ca04df6", "colab": { "base_uri": "https://localhost:8080/", "height": 202 } }, "source": [ "df = df.sort_values(\"Age\", ascending = False)\n", "df.head(5)" ], "execution_count": 13, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAge
63063111Barkworth, Mr. Algernon Henry Wilsonmale80.0
85185203Svensson, Mr. Johanmale74.0
49349401Artagaveytia, Mr. Ramonmale71.0
969701Goldschmidt, Mr. George Bmale71.0
11611703Connors, Mr. Patrickmale70.5
\n", "
" ], "text/plain": [ " PassengerId Survived ... Sex Age\n", "630 631 1 ... male 80.0\n", "851 852 0 ... male 74.0\n", "493 494 0 ... male 71.0\n", "96 97 0 ... male 71.0\n", "116 117 0 ... male 70.5\n", "\n", "[5 rows x 6 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 13 } ] }, { "cell_type": "markdown", "metadata": { "id": "Kz1O1_V6R-HJ", "colab_type": "text" }, "source": [ "# Filtering the dataset, or cleaning the dataset by selecting only the name and many more." ] }, { "cell_type": "code", "metadata": { "id": "2pRJSwAfj0Tg", "colab_type": "code", "outputId": "89222e4d-f164-40d6-cae6-4cf9ab0f5fd1", "colab": { "base_uri": "https://localhost:8080/", "height": 79 } }, "source": [ "result = df[df['Name'] == 'Svensson, Mr. Johan'\t]\n", "result\n" ], "execution_count": 14, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAge
85185203Svensson, Mr. Johanmale74.0
\n", "
" ], "text/plain": [ " PassengerId Survived Pclass Name Sex Age\n", "851 852 0 3 Svensson, Mr. Johan male 74.0" ] }, "metadata": { "tags": [] }, "execution_count": 14 } ] }, { "cell_type": "markdown", "metadata": { "id": "l9vxR0OnSoZV", "colab_type": "text" }, "source": [ "# Counting the occurences of variables\n" ] }, { "cell_type": "code", "metadata": { "id": "s9D1EHccSp2m", "colab_type": "code", "outputId": "22d7f136-96a7-46e0-e13b-a4740832d59a", "colab": { "base_uri": "https://localhost:8080/", "height": 69 } }, "source": [ "df[\"Sex\"].value_counts()\n" ], "execution_count": 15, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "male 577\n", "female 314\n", "Name: Sex, dtype: int64" ] }, "metadata": { "tags": [] }, "execution_count": 15 } ] }, { "cell_type": "markdown", "metadata": { "id": "rc8RlzWmS4g8", "colab_type": "text" }, "source": [ "# Using .nunique() to count number of unique values that occur in dataset or in a column" ] }, { "cell_type": "code", "metadata": { "id": "aKWYElPAS3-c", "colab_type": "code", "outputId": "5ddbdba8-ba69-43cc-9e96-827f1b341042", "colab": { "base_uri": "https://localhost:8080/", "height": 139 } }, "source": [ "df.nunique()" ], "execution_count": 16, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "PassengerId 891\n", "Survived 2\n", "Pclass 3\n", "Name 891\n", "Sex 2\n", "Age 88\n", "dtype: int64" ] }, "metadata": { "tags": [] }, "execution_count": 16 } ] }, { "cell_type": "markdown", "metadata": { "id": "fblOPIVxTLnp", "colab_type": "text" }, "source": [ "# Filtering" ] }, { "cell_type": "markdown", "metadata": { "id": "sDD70RkMTzxI", "colab_type": "text" }, "source": [ "**AND operator**" ] }, { "cell_type": "code", "metadata": { "id": "S6YVgGO9TMnR", "colab_type": "code", "outputId": "0f64281f-e6f7-4e8c-b540-6d616fb4308e", "colab": { "base_uri": "https://localhost:8080/", "height": 1949 } }, "source": [ "df_age = df[\"Age\"] < 50\n", "df_sex_mask = df[\"Sex\"] == \"female\"\n", "df[df_age & df_sex_mask]" ], "execution_count": 17, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAge
525311Harper, Mrs. Henry Sleeper (Myna Haxtun)female49.00
79679711Leader, Dr. Alice (Farnham)female49.00
75475512Herman, Mrs. Samuel (Jane Laver)female48.00
55655711Duff Gordon, Lady. (Lucille Christiana Sutherl...female48.00
73673703Ford, Mrs. Edward (Margaret Ann Watson)female48.00
86286311Swift, Mrs. Frederick Joel (Margaret Welles Ba...female48.00
13213303Robins, Mrs. Alexander A (Grace Charity Laury)female47.00
87187211Beckwith, Mrs. Richard Leonard (Sallie Monypeny)female47.00
70670712Kelly, Mrs. Florence \"Fannie\"female45.00
27627703Lindblom, Miss. Augusta Charlottafemale45.00
16716803Skoog, Mrs. William (Anna Bernhardina Karlsson)female45.00
36236303Barbara, Mrs. (Catherine David)female45.00
85685711Wick, Mrs. George Dennick (Mary Hitchcock)female45.00
44044112Hart, Mrs. Benjamin (Esther Ada Bloomfield)female45.00
52352411Hippach, Mrs. Louis Albert (Ida Sophia Fischer)female44.00
19419511Brown, Mrs. James Joseph (Margaret Tobin)female44.00
85485502Carter, Mrs. Ernest Courtenay (Lilian Hughes)female44.00
77978011Robert, Mrs. Edward Scott (Elisabeth Walton Mc...female43.00
67867903Goodwin, Mrs. Frederick (Augusta Tyler)female43.00
43243312Louch, Mrs. Charles Alexander (Alice Adelaide ...female42.00
86586612Bystrom, Mrs. (Karolina)female42.00
38038111Bidois, Miss. Rosaliefemale42.00
27227312Mellinger, Mrs. (Elizabeth Anne Maidment)female41.00
33733811Burns, Miss. Elizabeth Margaretfemale41.00
25425503Rosblom, Mrs. Viktor (Helena Wilhelmina)female41.00
63863903Panula, Mrs. Juha (Maria Emilia Ojala)female41.00
60961011Shutes, Miss. Elizabeth Wfemale40.00
31932011Spedden, Mrs. Frederic Oakley (Margaretta Corn...female40.00
16116212Watt, Mrs. James (Elizabeth \"Bessie\" Inglis Mi...female40.00
34634712Smith, Miss. Marion Elsiefemale40.00
.....................
63463503Skoog, Miss. Mabelfemale9.00
85285303Boulos, Miss. Nourelainfemale9.00
54154203Andersson, Miss. Ingeborg Constanziafemale9.00
14714803Ford, Miss. Robina Maggie \"Ruby\"female9.00
242503Palsson, Miss. Torborg Danirafemale8.00
23723812Collyer, Miss. Marjorie \"Lottie\"female8.00
53553612Hart, Miss. Eva Miriamfemale7.00
72072112Harper, Miss. Annie Jessie \"Nina\"female6.00
81381403Andersson, Miss. Ebba Iris Alfridafemale6.00
77777813Emanuel, Miss. Virginia Ethelfemale5.00
23323413Asplund, Miss. Lillian Gertrudfemale5.00
585912West, Miss. Constance Miriumfemale5.00
44844913Baclini, Miss. Marie Catherinefemale5.00
69169213Karun, Miss. Mancafemale4.00
101113Sandstrom, Miss. Marguerite Rutfemale4.00
75075112Wells, Miss. Joanfemale4.00
18418513Kink-Heilmann, Miss. Luise Gretchenfemale4.00
61861912Becker, Miss. Marion Louisefemale4.00
434412Laroche, Miss. Simonne Marie Anne Andreefemale3.00
37437503Palsson, Miss. Stina Violafemale3.00
64264303Skoog, Miss. Margit Elizabethfemale2.00
20520603Strom, Miss. Telma Matildafemale2.00
53053112Quick, Miss. Phyllis Mayfemale2.00
47948013Hirvonen, Miss. Hildur Efemale2.00
29729801Allison, Miss. Helen Lorainefemale2.00
11912003Andersson, Miss. Ellis Anna Mariafemale2.00
38138213Nakid, Miss. Maria (\"Mary\")female1.00
17217313Johnson, Miss. Eleanor Ileenfemale1.00
64464513Baclini, Miss. Eugeniefemale0.75
46947013Baclini, Miss. Helene Barbarafemale0.75
\n", "

239 rows × 6 columns

\n", "
" ], "text/plain": [ " PassengerId Survived ... Sex Age\n", "52 53 1 ... female 49.00\n", "796 797 1 ... female 49.00\n", "754 755 1 ... female 48.00\n", "556 557 1 ... female 48.00\n", "736 737 0 ... female 48.00\n", "862 863 1 ... female 48.00\n", "132 133 0 ... female 47.00\n", "871 872 1 ... female 47.00\n", "706 707 1 ... female 45.00\n", "276 277 0 ... female 45.00\n", "167 168 0 ... female 45.00\n", "362 363 0 ... female 45.00\n", "856 857 1 ... female 45.00\n", "440 441 1 ... female 45.00\n", "523 524 1 ... female 44.00\n", "194 195 1 ... female 44.00\n", "854 855 0 ... female 44.00\n", "779 780 1 ... female 43.00\n", "678 679 0 ... female 43.00\n", "432 433 1 ... female 42.00\n", "865 866 1 ... female 42.00\n", "380 381 1 ... female 42.00\n", "272 273 1 ... female 41.00\n", "337 338 1 ... female 41.00\n", "254 255 0 ... female 41.00\n", "638 639 0 ... female 41.00\n", "609 610 1 ... female 40.00\n", "319 320 1 ... female 40.00\n", "161 162 1 ... female 40.00\n", "346 347 1 ... female 40.00\n", ".. ... ... ... ... ...\n", "634 635 0 ... female 9.00\n", "852 853 0 ... female 9.00\n", "541 542 0 ... female 9.00\n", "147 148 0 ... female 9.00\n", "24 25 0 ... female 8.00\n", "237 238 1 ... female 8.00\n", "535 536 1 ... female 7.00\n", "720 721 1 ... female 6.00\n", "813 814 0 ... female 6.00\n", "777 778 1 ... female 5.00\n", "233 234 1 ... female 5.00\n", "58 59 1 ... female 5.00\n", "448 449 1 ... female 5.00\n", "691 692 1 ... female 4.00\n", "10 11 1 ... female 4.00\n", "750 751 1 ... female 4.00\n", "184 185 1 ... female 4.00\n", "618 619 1 ... female 4.00\n", "43 44 1 ... female 3.00\n", "374 375 0 ... female 3.00\n", "642 643 0 ... female 2.00\n", "205 206 0 ... female 2.00\n", "530 531 1 ... female 2.00\n", "479 480 1 ... female 2.00\n", "297 298 0 ... female 2.00\n", "119 120 0 ... female 2.00\n", "381 382 1 ... female 1.00\n", "172 173 1 ... female 1.00\n", "644 645 1 ... female 0.75\n", "469 470 1 ... female 0.75\n", "\n", "[239 rows x 6 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 17 } ] }, { "cell_type": "markdown", "metadata": { "id": "fZwQ2i6OT9vN", "colab_type": "text" }, "source": [ "**OR operator**" ] }, { "cell_type": "code", "metadata": { "id": "8Tsj5DIuUAyb", "colab_type": "code", "outputId": "fcae74bc-81b2-4d49-86a9-2aada60d9309", "colab": { "base_uri": "https://localhost:8080/", "height": 202 } }, "source": [ "df_sex = df[\"Sex\"] == \"Male\"\n", "df_age_mask = df[\"Age\"] > 70\n", "df[df_sex | df_age_mask]" ], "execution_count": 18, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAge
63063111Barkworth, Mr. Algernon Henry Wilsonmale80.0
85185203Svensson, Mr. Johanmale74.0
49349401Artagaveytia, Mr. Ramonmale71.0
969701Goldschmidt, Mr. George Bmale71.0
11611703Connors, Mr. Patrickmale70.5
\n", "
" ], "text/plain": [ " PassengerId Survived ... Sex Age\n", "630 631 1 ... male 80.0\n", "851 852 0 ... male 74.0\n", "493 494 0 ... male 71.0\n", "96 97 0 ... male 71.0\n", "116 117 0 ... male 70.5\n", "\n", "[5 rows x 6 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 18 } ] }, { "cell_type": "markdown", "metadata": { "id": "SF--tZmHUWQg", "colab_type": "text" }, "source": [ "# Finding the null values with .isnull()\n" ] }, { "cell_type": "code", "metadata": { "id": "AIH5Uq67UXJ_", "colab_type": "code", "outputId": "9f6709aa-a5c3-4287-e8f8-f5a93739d6a2", "colab": { "base_uri": "https://localhost:8080/", "height": 1949 } }, "source": [ "null_mask = df[\"Age\"].isnull()\n", "df[null_mask]" ], "execution_count": 19, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAge
5603Moran, Mr. JamesmaleNaN
171812Williams, Mr. Charles EugenemaleNaN
192013Masselmani, Mrs. FatimafemaleNaN
262703Emir, Mr. Farred ChehabmaleNaN
282913O'Dwyer, Miss. Ellen \"Nellie\"femaleNaN
293003Todoroff, Mr. LaliomaleNaN
313211Spencer, Mrs. William Augustus (Marie Eugenie)femaleNaN
323313Glynn, Miss. Mary AgathafemaleNaN
363713Mamee, Mr. HannamaleNaN
424303Kraeff, Mr. TheodormaleNaN
454603Rogers, Mr. William JohnmaleNaN
464703Lennon, Mr. DenismaleNaN
474813O'Driscoll, Miss. BridgetfemaleNaN
484903Samaan, Mr. YoussefmaleNaN
555611Woolner, Mr. HughmaleNaN
646501Stewart, Mr. Albert AmaleNaN
656613Moubarek, Master. GeriosmaleNaN
767703Staneff, Mr. IvanmaleNaN
777803Moutal, Mr. Rahamin HaimmaleNaN
828313McDermott, Miss. Brigdet DeliafemaleNaN
878803Slocovski, Mr. Selman FrancismaleNaN
959603Shorney, Mr. Charles JosephmaleNaN
10110203Petroff, Mr. Pastcho (\"Pentcho\")maleNaN
10710813Moss, Mr. Albert JohanmaleNaN
10911013Moran, Miss. BerthafemaleNaN
12112203Moore, Mr. Leonard CharlesmaleNaN
12612703McMahon, Mr. MartinmaleNaN
12812913Peter, Miss. AnnafemaleNaN
14014103Boulos, Mrs. Joseph (Sultana)femaleNaN
15415503Olsen, Mr. Ole MartinmaleNaN
.....................
71871903McEvoy, Mr. MichaelmaleNaN
72772813Mannion, Miss. MargarethfemaleNaN
73273302Knight, Mr. Robert JmaleNaN
73873903Ivanoff, Mr. KaniomaleNaN
73974003Nankoff, Mr. MinkomaleNaN
74074111Hawksford, Mr. Walter JamesmaleNaN
76076103Garfirth, Mr. JohnmaleNaN
76676701Brewe, Dr. Arthur JacksonmaleNaN
76876903Moran, Mr. Daniel JmaleNaN
77377403Elias, Mr. DibomaleNaN
77677703Tobin, Mr. RogermaleNaN
77877903Kilgannon, Mr. Thomas JmaleNaN
78378403Johnston, Mr. Andrew GmaleNaN
79079103Keane, Mr. Andrew \"Andy\"maleNaN
79279303Sage, Miss. Stella AnnafemaleNaN
79379401Hoyt, Mr. William FishermaleNaN
81581601Fry, Mr. RichardmaleNaN
82582603Flynn, Mr. JohnmaleNaN
82682703Lam, Mr. LenmaleNaN
82882913McCormack, Mr. Thomas JosephmaleNaN
83283303Saad, Mr. AminmaleNaN
83783803Sirota, Mr. MauricemaleNaN
83984011Marechal, Mr. PierremaleNaN
84684703Sage, Mr. Douglas BullenmaleNaN
84985011Goldenberg, Mrs. Samuel L (Edwiga Grabowska)femaleNaN
85986003Razi, Mr. RaihedmaleNaN
86386403Sage, Miss. Dorothy Edith \"Dolly\"femaleNaN
86886903van Melkebeke, Mr. PhilemonmaleNaN
87887903Laleff, Mr. KristomaleNaN
88888903Johnston, Miss. Catherine Helen \"Carrie\"femaleNaN
\n", "

177 rows × 6 columns

\n", "
" ], "text/plain": [ " PassengerId Survived ... Sex Age\n", "5 6 0 ... male NaN\n", "17 18 1 ... male NaN\n", "19 20 1 ... female NaN\n", "26 27 0 ... male NaN\n", "28 29 1 ... female NaN\n", "29 30 0 ... male NaN\n", "31 32 1 ... female NaN\n", "32 33 1 ... female NaN\n", "36 37 1 ... male NaN\n", "42 43 0 ... male NaN\n", "45 46 0 ... male NaN\n", "46 47 0 ... male NaN\n", "47 48 1 ... female NaN\n", "48 49 0 ... male NaN\n", "55 56 1 ... male NaN\n", "64 65 0 ... male NaN\n", "65 66 1 ... male NaN\n", "76 77 0 ... male NaN\n", "77 78 0 ... male NaN\n", "82 83 1 ... female NaN\n", "87 88 0 ... male NaN\n", "95 96 0 ... male NaN\n", "101 102 0 ... male NaN\n", "107 108 1 ... male NaN\n", "109 110 1 ... female NaN\n", "121 122 0 ... male NaN\n", "126 127 0 ... male NaN\n", "128 129 1 ... female NaN\n", "140 141 0 ... female NaN\n", "154 155 0 ... male NaN\n", ".. ... ... ... ... ..\n", "718 719 0 ... male NaN\n", "727 728 1 ... female NaN\n", "732 733 0 ... male NaN\n", "738 739 0 ... male NaN\n", "739 740 0 ... male NaN\n", "740 741 1 ... male NaN\n", "760 761 0 ... male NaN\n", "766 767 0 ... male NaN\n", "768 769 0 ... male NaN\n", "773 774 0 ... male NaN\n", "776 777 0 ... male NaN\n", "778 779 0 ... male NaN\n", "783 784 0 ... male NaN\n", "790 791 0 ... male NaN\n", "792 793 0 ... female NaN\n", "793 794 0 ... male NaN\n", "815 816 0 ... male NaN\n", "825 826 0 ... male NaN\n", "826 827 0 ... male NaN\n", "828 829 1 ... male NaN\n", "832 833 0 ... male NaN\n", "837 838 0 ... male NaN\n", "839 840 1 ... male NaN\n", "846 847 0 ... male NaN\n", "849 850 1 ... female NaN\n", "859 860 0 ... male NaN\n", "863 864 0 ... female NaN\n", "868 869 0 ... male NaN\n", "878 879 0 ... male NaN\n", "888 889 0 ... female NaN\n", "\n", "[177 rows x 6 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 19 } ] }, { "cell_type": "code", "metadata": { "id": "XhupjmknUt9w", "colab_type": "code", "outputId": "550be23c-bf39-4501-a00b-a95ae6fb2c28", "colab": { "base_uri": "https://localhost:8080/", "height": 139 } }, "source": [ "df.isnull().sum()\n" ], "execution_count": 20, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "PassengerId 0\n", "Survived 0\n", "Pclass 0\n", "Name 0\n", "Sex 0\n", "Age 177\n", "dtype: int64" ] }, "metadata": { "tags": [] }, "execution_count": 20 } ] }, { "cell_type": "markdown", "metadata": { "id": "kG9rV4NZU0YU", "colab_type": "text" }, "source": [ "# Dropping a column\n" ] }, { "cell_type": "code", "metadata": { "id": "St1zpvX4U1tI", "colab_type": "code", "outputId": "0eca5d14-baa9-4cc7-d005-50a366f2109a", "colab": { "base_uri": "https://localhost:8080/", "height": 202 } }, "source": [ "df.drop(labels = [\"Pclass\"], axis=1).head()" ], "execution_count": 21, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedNameSexAge
6306311Barkworth, Mr. Algernon Henry Wilsonmale80.0
8518520Svensson, Mr. Johanmale74.0
4934940Artagaveytia, Mr. Ramonmale71.0
96970Goldschmidt, Mr. George Bmale71.0
1161170Connors, Mr. Patrickmale70.5
\n", "
" ], "text/plain": [ " PassengerId Survived Name Sex Age\n", "630 631 1 Barkworth, Mr. Algernon Henry Wilson male 80.0\n", "851 852 0 Svensson, Mr. Johan male 74.0\n", "493 494 0 Artagaveytia, Mr. Ramon male 71.0\n", "96 97 0 Goldschmidt, Mr. George B male 71.0\n", "116 117 0 Connors, Mr. Patrick male 70.5" ] }, "metadata": { "tags": [] }, "execution_count": 21 } ] }, { "cell_type": "markdown", "metadata": { "id": "cr-iKp_IVJzl", "colab_type": "text" }, "source": [ "**Replacing the values by using the replace method**" ] }, { "cell_type": "code", "metadata": { "id": "hF3no_nLVJQC", "colab_type": "code", "outputId": "ed8f7025-c13d-4089-900a-cedff07f9fb1", "colab": { "base_uri": "https://localhost:8080/", "height": 1949 } }, "source": [ "df.replace(\"Nan\",df[\"Age\"].median())\n", "\n", "df.replace(\"Masselmani, Mrs. Fatima\", \"Tanu\")\n" ], "execution_count": 22, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PassengerIdSurvivedPclassNameSexAge
63063111Barkworth, Mr. Algernon Henry Wilsonmale80.0
85185203Svensson, Mr. Johanmale74.0
49349401Artagaveytia, Mr. Ramonmale71.0
969701Goldschmidt, Mr. George Bmale71.0
11611703Connors, Mr. Patrickmale70.5
67267302Mitchell, Mr. Henry Michaelmale70.0
74574601Crosby, Capt. Edward Giffordmale70.0
333402Wheadon, Mr. Edward Hmale66.0
545501Ostby, Mr. Engelhart Corneliusmale65.0
28028103Duane, Mr. Frankmale65.0
45645701Millet, Mr. Francis Davismale65.0
43843901Fortune, Mr. Markmale64.0
54554601Nicholson, Mr. Arthur Ernestmale64.0
27527611Andrews, Miss. Kornelia Theodosiafemale63.0
48348413Turkula, Mrs. (Hedwig)female63.0
57057112Harris, Mr. Georgemale62.0
25225301Stead, Mr. William Thomasmale62.0
82983011Stone, Mrs. George Nelson (Martha Evelyn)female62.0
55555601Wright, Mr. Georgemale62.0
62562601Sutton, Mr. Frederickmale61.0
32632703Nysveen, Mr. Johan Hansenmale61.0
17017101Van der hoef, Mr. Wyckoffmale61.0
68468502Brown, Mr. Thomas William Solomonmale60.0
69469501Weir, Col. Johnmale60.0
58758811Frolicher-Stehli, Mr. Maxmillianmale60.0
36636711Warren, Mrs. Frank Manley (Anna Sophia Atkinson)female60.0
949503Coxon, Mr. Danielmale59.0
23223302Sjostedt, Mr. Ernst Adolfmale59.0
26826911Graham, Mrs. William Thompson (Edith Junkins)female58.0
111211Bonnell, Miss. Elizabethfemale58.0
.....................
71871903McEvoy, Mr. MichaelmaleNaN
72772813Mannion, Miss. MargarethfemaleNaN
73273302Knight, Mr. Robert JmaleNaN
73873903Ivanoff, Mr. KaniomaleNaN
73974003Nankoff, Mr. MinkomaleNaN
74074111Hawksford, Mr. Walter JamesmaleNaN
76076103Garfirth, Mr. JohnmaleNaN
76676701Brewe, Dr. Arthur JacksonmaleNaN
76876903Moran, Mr. Daniel JmaleNaN
77377403Elias, Mr. DibomaleNaN
77677703Tobin, Mr. RogermaleNaN
77877903Kilgannon, Mr. Thomas JmaleNaN
78378403Johnston, Mr. Andrew GmaleNaN
79079103Keane, Mr. Andrew \"Andy\"maleNaN
79279303Sage, Miss. Stella AnnafemaleNaN
79379401Hoyt, Mr. William FishermaleNaN
81581601Fry, Mr. RichardmaleNaN
82582603Flynn, Mr. JohnmaleNaN
82682703Lam, Mr. LenmaleNaN
82882913McCormack, Mr. Thomas JosephmaleNaN
83283303Saad, Mr. AminmaleNaN
83783803Sirota, Mr. MauricemaleNaN
83984011Marechal, Mr. PierremaleNaN
84684703Sage, Mr. Douglas BullenmaleNaN
84985011Goldenberg, Mrs. Samuel L (Edwiga Grabowska)femaleNaN
85986003Razi, Mr. RaihedmaleNaN
86386403Sage, Miss. Dorothy Edith \"Dolly\"femaleNaN
86886903van Melkebeke, Mr. PhilemonmaleNaN
87887903Laleff, Mr. KristomaleNaN
88888903Johnston, Miss. Catherine Helen \"Carrie\"femaleNaN
\n", "

891 rows × 6 columns

\n", "
" ], "text/plain": [ " PassengerId Survived ... Sex Age\n", "630 631 1 ... male 80.0\n", "851 852 0 ... male 74.0\n", "493 494 0 ... male 71.0\n", "96 97 0 ... male 71.0\n", "116 117 0 ... male 70.5\n", "672 673 0 ... male 70.0\n", "745 746 0 ... male 70.0\n", "33 34 0 ... male 66.0\n", "54 55 0 ... male 65.0\n", "280 281 0 ... male 65.0\n", "456 457 0 ... male 65.0\n", "438 439 0 ... male 64.0\n", "545 546 0 ... male 64.0\n", "275 276 1 ... female 63.0\n", "483 484 1 ... female 63.0\n", "570 571 1 ... male 62.0\n", "252 253 0 ... male 62.0\n", "829 830 1 ... female 62.0\n", "555 556 0 ... male 62.0\n", "625 626 0 ... male 61.0\n", "326 327 0 ... male 61.0\n", "170 171 0 ... male 61.0\n", "684 685 0 ... male 60.0\n", "694 695 0 ... male 60.0\n", "587 588 1 ... male 60.0\n", "366 367 1 ... female 60.0\n", "94 95 0 ... male 59.0\n", "232 233 0 ... male 59.0\n", "268 269 1 ... female 58.0\n", "11 12 1 ... female 58.0\n", ".. ... ... ... ... ...\n", "718 719 0 ... male NaN\n", "727 728 1 ... female NaN\n", "732 733 0 ... male NaN\n", "738 739 0 ... male NaN\n", "739 740 0 ... male NaN\n", "740 741 1 ... male NaN\n", "760 761 0 ... male NaN\n", "766 767 0 ... male NaN\n", "768 769 0 ... male NaN\n", "773 774 0 ... male NaN\n", "776 777 0 ... male NaN\n", "778 779 0 ... male NaN\n", "783 784 0 ... male NaN\n", "790 791 0 ... male NaN\n", "792 793 0 ... female NaN\n", "793 794 0 ... male NaN\n", "815 816 0 ... male NaN\n", "825 826 0 ... male NaN\n", "826 827 0 ... male NaN\n", "828 829 1 ... male NaN\n", "832 833 0 ... male NaN\n", "837 838 0 ... male NaN\n", "839 840 1 ... male NaN\n", "846 847 0 ... male NaN\n", "849 850 1 ... female NaN\n", "859 860 0 ... male NaN\n", "863 864 0 ... female NaN\n", "868 869 0 ... male NaN\n", "878 879 0 ... male NaN\n", "888 889 0 ... female NaN\n", "\n", "[891 rows x 6 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 22 } ] }, { "cell_type": "markdown", "metadata": { "id": "AX07UhV8iv30", "colab_type": "text" }, "source": [ "# Let us calculate how many passengers survived.\n", "Here 1 = survived, and 0 = Not survived.\n" ] }, { "cell_type": "code", "metadata": { "id": "4s7zbGQvgiKT", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 121 }, "outputId": "5e2f3eae-1259-4fff-92a2-d692389e1b81" }, "source": [ "count = df['Survived'].value_counts()\n", "print(count)\n", "# Let us see that in percentage.\n", "\n", "percentage = df['Survived'].value_counts() * 100 / len(df)\n", "print(percentage)" ], "execution_count": 41, "outputs": [ { "output_type": "stream", "text": [ "0 549\n", "1 342\n", "Name: Survived, dtype: int64\n", "0 61.616162\n", "1 38.383838\n", "Name: Survived, dtype: float64\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "ocTuGos1kXMM", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 283 }, "outputId": "c739fbd9-3965-4373-f74a-87f9a8da3636" }, "source": [ "%matplotlib inline\n", "color = 0.5\n", "df['Survived'].value_counts().plot(kind = 'bar')" ], "execution_count": 42, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "" ] }, "metadata": { "tags": [] }, "execution_count": 42 }, { "output_type": "display_data", "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAADBxJREFUeJzt3V+MpfVdx/H3p2ypxpouf8YN7q4u\nCZs0eFFKJoipFwpR+WNcLlpCY2RDNtkbmrSpiV29MU28gBtREkOykepitJRUGzaUqGQLMcZAGSzS\nUqyMBLK7AXZKAW1IVcrXi/ltOq67zJmdM5zd775fyeQ8z+/5nfP8Jtm8eXjmnJlUFZKkvt436wVI\nkjaWoZek5gy9JDVn6CWpOUMvSc0ZeklqztBLUnOGXpKaM/SS1NymWS8A4OKLL64dO3bMehmSdFZ5\n6qmnvltVc6vNOyNCv2PHDhYWFma9DEk6qyR5aZJ53rqRpOYMvSQ1Z+glqTlDL0nNGXpJas7QS1Jz\nhl6SmjP0ktTcGfGBqbPFjn1fnfUSWnnxjhtnvQTpnOAVvSQ1Z+glqTlDL0nNGXpJas7QS1Jzhl6S\nmjP0ktScoZek5gy9JDVn6CWpOUMvSc0ZeklqztBLUnOGXpKaM/SS1NxEoU/yYpJvJnk6ycIYuzDJ\nI0meH48XjPEkuTvJYpJnkly5kd+AJOndreWK/per6oqqmh/7+4BDVbUTODT2Aa4Hdo6vvcA901qs\nJGnt1nPrZhdwYGwfAG5aMX5fLXsc2JzkknWcR5K0DpOGvoC/T/JUkr1jbE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R/zZnYyNu3RwFtq/Y3zbGJEkzsBGhfxLYmeTSJOcDtwAHN+A8kqQJTP3WTVW9neRTwN8B\n5wFfqKpnp30evStvielM5b/NGUhVzXoNkqQN5CdjJak5Qy9JzRl6SWpuZu+j13Qk+TDLnzzeOoaO\nAger6rnZrUrSmcQr+rNYks+x/CsmAnx9fAX4or9MTtJxvuvmLJbk34Cfq6r/OWH8fODZqto5m5VJ\n7y7JbVX1Z7Nex7nCK/qz2zvAT59k/JJxTDpTfX7WCziXeI/+7PYZ4FCS5/nRL5L7GeAy4FMzW5UE\nJHnmVIeALe/lWs513ro5yyV5H8u/GnrlD2OfrKofzm5VEiR5Ffg14PUTDwH/VFUn+79RbQCv6M9y\nVfUO8Pis1yGdxEPAB6vq6RMPJHnsvV/Oucsreklqzh/GSlJzhl6SmjP0ktScoZek5v4XlOOeFpX9\nVMgAAAAASUVORK5CYII=\n", "text/plain": [ "
" ] }, "metadata": { "tags": [] } } ] }, { "cell_type": "markdown", "metadata": { "id": "VdEe36TRWnYA", "colab_type": "text" }, "source": [ "**I think this much more than enough for a good start to just starting and master data analysis on the web. Further, I will add more concepts, snippets, and examples in class to make things clear**" ] }, { "cell_type": "markdown", "metadata": { "id": "oOijhEeyYMNz", "colab_type": "text" }, "source": [ "\n", "\n", "[Click Here to watch the video](https://www.youtube.com/watch?v=DNyKDI9pn0Q)\n" ] } ] }