{ "cells": [ { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "doOoC294Grdq" }, "source": [ "# **Python practical for Data Science**\n", "-----\n", "\n", "## **Introduction**\n", "\n", "This guide explores best practices and fundamental knowledge that will allow you to perform data analysis using Python. In this guide, you will learn how to use Jupyter notebooks and Python libraries such as Pandas, Matplotlib or Numpy to easily and transparently explore and analyze your dataset.\n", "\n", "\n", "## **What is Data Science?**\n", "\n", "Essentially, [Data Science](https://en.wikipedia.org/wiki/Data_science) is about* extracting knowledge* from *massive amounts of data* to generate information. This is essentially done using several disciplines such as Mathematics and Computer Science such as statistics, probabilistic models, machine learning, data storage, computer programming, and so on.\n", "\n", "For more information, We invite readers to take a look at [this book](https://www.amazon.com/Data-Science-Scratch-Principles-Python/dp/149190142X).\n", "\n", "##**Prerequisites**\n", "\n", "It is necessary to be initiated into *Python programming* before attending this guide. We will also refer to the basic notions of *probability and statistics*, as well as *relational algebra*.\n", "\n", "##**Main purposes**\n", "\n", "After following this guide, readers should familiarize themselves with the following tasks:\n", "\n", "\n", "* Creating and installing Python modules;\n", "* Modification and use of Jupyter notebooks;\n", "* Data visualization with `Matplotlib` and `Seaborn`;\n", "* Handling tables with `Numpy`;\n", "* Handling a dataset with `Pandas`.\n", "\n", "\n", "##**Guide program**\n", "\n", "We will propose a hierarchical content according to the following plan:\n", "\n", "\n", "\n", "1. Setup your work environment;\n", "2. Get started with Python;\n", "3. Manipulate data using Numpy and Matplotlib;\n", "4. Deal with a large amount of data using Pandas library.\n", "\n", "Let's get started.\n", "\n", "###**1. Setup your work environment;**\n", "\n", "In order to begin analyzing data with Python, we need to have some background, as with all other relevant topics. Now, we will try to explain how to install Jupyter on your own machine.\n", "\n", "In case you don't have Python yet, it is possible to install Python, including all the necessary libraries, and the Jupyter notebook directly, by using [this solution](https://jupyter.org/install.html).\n", "Once Python has been previously installed, you will need to install the Jupyter notebook, as well as the following libraries: `Pandas` , `Matplotlib` , `Numpy` and `SciPy`.\n", " \n", "\n", "In practice, there are two possible solutions to install the Jupyter notebook and its necessary libraries:\n", "\n", "\n", "\n", "* Full installation in conjunction with the Anaconda distribution;\n", "* Installation of the Jupyter notebook exclusively (without Anaconda).\n", "\n", "\n", "**1.1. Full installation in conjunction with the Anaconda distribution**\n", "\n", "For those who have never installed Python, it is recommended to install the Anaconda distribution directly. This is what we will do in this section. Note that Anaconda is therefore a Python distribution, developed for Data Science.\n", "\n", "Everything we need, Anaconda will install everything we need, certainly, but it can install a little too much (libraries that we won't use, and so on). You can download an improved version of Anaconda here: [Download](https://conda.io/en/latest/). However, libraries, especially Jupyter, will not be installed automatically for this purpose. As a result, this is a solution for experienced users.\n", "\n", "\n", "On [this page](http://docs.anaconda.com/anaconda/install) you will find the formal installation instructions in case these instructions are no longer effective.\n", "\n", "\n", "In order to install Anaconda on Windows or MacOs, you must:\n", "\n", "* (1) Download the setup file for [Windows](https://www.anaconda.com/distribution/#windows) or [MacOs](https://www.anaconda.com/distribution/#macos), then launch it by double-clicking on the downloaded file;\n", "* (2) Once the installation is finished, make sure that everything has been done by executing the Jupyter program\n", "\n", "In case of any issues when installing Anaconda, please discuss them on [this community](https://www.anaconda.com/anaconda-community/). \n", "\n", "** 1.2. Installation of the Jupyter notebook exclusively (without Anaconda)**\n", "\n", "To avoid installing Anaconda, you can follow the following instructions after you have installed Python:\n", "\n", "* Check that the `pip program` is installed on your machine. For that, you just type `pip` into a console. Usually, the pip program was started at the same time as Python. Next, input these codelines successively:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 836 }, "colab_type": "code", "id": "hnMfzYYKG4K2", "outputId": "1e213f95-9ed8-4d30-9e5a-1f601bca1f6e" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already up-to-date: pip in /usr/local/lib/python3.6/dist-packages (19.0.3)\n", "Requirement already satisfied: jupyter in /usr/local/lib/python3.6/dist-packages (1.0.0)\n", "Requirement already satisfied: ipywidgets in /usr/local/lib/python3.6/dist-packages (from jupyter) (7.4.2)\n", "Requirement already satisfied: notebook in /usr/local/lib/python3.6/dist-packages (from jupyter) (5.2.2)\n", "Requirement already satisfied: jupyter-console in /usr/local/lib/python3.6/dist-packages (from jupyter) (6.0.0)\n", "Requirement already satisfied: qtconsole in /usr/local/lib/python3.6/dist-packages (from jupyter) (4.4.3)\n", "Requirement already satisfied: nbconvert in /usr/local/lib/python3.6/dist-packages (from jupyter) (5.4.1)\n", "Requirement already satisfied: ipykernel in /usr/local/lib/python3.6/dist-packages (from jupyter) (4.6.1)\n", "Requirement already satisfied: ipython>=4.0.0; python_version >= \"3.3\" in /usr/local/lib/python3.6/dist-packages (from ipywidgets->jupyter) (5.5.0)\n", "Requirement already satisfied: widgetsnbextension~=3.4.0 in /usr/local/lib/python3.6/dist-packages (from ipywidgets->jupyter) (3.4.2)\n", "Requirement already satisfied: nbformat>=4.2.0 in /usr/local/lib/python3.6/dist-packages (from ipywidgets->jupyter) (4.4.0)\n", "Requirement already satisfied: traitlets>=4.3.1 in /usr/local/lib/python3.6/dist-packages (from ipywidgets->jupyter) (4.3.2)\n", "Requirement already satisfied: jupyter-client in /usr/local/lib/python3.6/dist-packages (from notebook->jupyter) (5.2.4)\n", "Requirement already satisfied: jinja2 in /usr/local/lib/python3.6/dist-packages (from notebook->jupyter) (2.10)\n", "Requirement already satisfied: tornado>=4 in /usr/local/lib/python3.6/dist-packages (from notebook->jupyter) (4.5.3)\n", "Requirement already satisfied: terminado>=0.3.3; sys_platform != \"win32\" in /usr/local/lib/python3.6/dist-packages (from notebook->jupyter) (0.8.1)\n", "Requirement already satisfied: ipython-genutils in /usr/local/lib/python3.6/dist-packages (from notebook->jupyter) (0.2.0)\n", "Requirement already satisfied: jupyter-core in /usr/local/lib/python3.6/dist-packages (from notebook->jupyter) (4.4.0)\n", "Requirement already satisfied: pygments in /usr/local/lib/python3.6/dist-packages (from jupyter-console->jupyter) (2.1.3)\n", "Collecting prompt-toolkit<2.1.0,>=2.0.0 (from jupyter-console->jupyter)\n", "\u001b[?25l Downloading https://files.pythonhosted.org/packages/f7/a7/9b1dd14ef45345f186ef69d175bdd2491c40ab1dfa4b2b3e4352df719ed7/prompt_toolkit-2.0.9-py3-none-any.whl (337kB)\n", "\u001b[K 100% |████████████████████████████████| 337kB 26.5MB/s \n", "\u001b[?25hRequirement already satisfied: testpath in /usr/local/lib/python3.6/dist-packages (from nbconvert->jupyter) (0.4.2)\n", "Requirement already satisfied: bleach in /usr/local/lib/python3.6/dist-packages (from nbconvert->jupyter) (3.1.0)\n", "Requirement already satisfied: defusedxml in /usr/local/lib/python3.6/dist-packages (from nbconvert->jupyter) (0.5.0)\n", "Requirement already satisfied: pandocfilters>=1.4.1 in /usr/local/lib/python3.6/dist-packages (from nbconvert->jupyter) (1.4.2)\n", "Requirement already satisfied: entrypoints>=0.2.2 in /usr/local/lib/python3.6/dist-packages (from nbconvert->jupyter) (0.3)\n", "Requirement already satisfied: mistune>=0.8.1 in /usr/local/lib/python3.6/dist-packages (from nbconvert->jupyter) (0.8.4)\n", "Requirement already satisfied: pexpect; sys_platform != \"win32\" in /usr/local/lib/python3.6/dist-packages (from ipython>=4.0.0; python_version >= \"3.3\"->ipywidgets->jupyter) (4.6.0)\n", "Requirement already satisfied: simplegeneric>0.8 in /usr/local/lib/python3.6/dist-packages (from ipython>=4.0.0; python_version >= \"3.3\"->ipywidgets->jupyter) (0.8.1)\n", "Requirement already satisfied: setuptools>=18.5 in /usr/local/lib/python3.6/dist-packages (from ipython>=4.0.0; python_version >= \"3.3\"->ipywidgets->jupyter) (40.8.0)\n", "Requirement already satisfied: pickleshare in /usr/local/lib/python3.6/dist-packages (from ipython>=4.0.0; python_version >= \"3.3\"->ipywidgets->jupyter) (0.7.5)\n", "Requirement already satisfied: decorator in /usr/local/lib/python3.6/dist-packages (from ipython>=4.0.0; python_version >= \"3.3\"->ipywidgets->jupyter) (4.4.0)\n", "Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /usr/local/lib/python3.6/dist-packages (from nbformat>=4.2.0->ipywidgets->jupyter) (2.6.0)\n", "Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from traitlets>=4.3.1->ipywidgets->jupyter) (1.11.0)\n", "Requirement already satisfied: pyzmq>=13 in /usr/local/lib/python3.6/dist-packages (from jupyter-client->notebook->jupyter) (17.0.0)\n", "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from jupyter-client->notebook->jupyter) (2.5.3)\n", "Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.6/dist-packages (from jinja2->notebook->jupyter) (1.1.1)\n", "Requirement already satisfied: ptyprocess; os_name != \"nt\" in /usr/local/lib/python3.6/dist-packages (from terminado>=0.3.3; sys_platform != \"win32\"->notebook->jupyter) (0.6.0)\n", "Requirement already satisfied: wcwidth in /usr/local/lib/python3.6/dist-packages (from prompt-toolkit<2.1.0,>=2.0.0->jupyter-console->jupyter) (0.1.7)\n", "Requirement already satisfied: webencodings in /usr/local/lib/python3.6/dist-packages (from bleach->nbconvert->jupyter) (0.5.1)\n", "\u001b[31mipython 5.5.0 has requirement prompt-toolkit<2.0.0,>=1.0.4, but you'll have prompt-toolkit 2.0.9 which is incompatible.\u001b[0m\n", "Installing collected packages: prompt-toolkit\n", " Found existing installation: prompt-toolkit 1.0.15\n", " Uninstalling prompt-toolkit-1.0.15:\n", " Successfully uninstalled prompt-toolkit-1.0.15\n", "Successfully installed prompt-toolkit-2.0.9\n" ] } ], "source": [ "!python -m pip install --upgrade pip \n", "!python -m pip install jupyter" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "S9VuAmUOIgtx" }, "source": [ "By typing the following command in your console, you can verify if the setup went well:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 153 }, "colab_type": "code", "id": "bhb_k8YdIiEj", "outputId": "443f3cbb-b56e-447a-93b4-36ebb2d24834" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "|INFO|google.colab serverextension initialized.\n", "|INFO|Serving notebooks from local directory: /content\n", "|INFO|0 active kernels\n", "|INFO|The Jupyter Notebook is running at:\n", "|INFO|http://localhost:8888/\n", "|INFO|Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).\n", "|CRITICAL|received signal 2, stopping\n", "|INFO|Shutting down 0 kernels\n" ] } ], "source": [ " !jupyter notebook" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "Zj7YIvGkM3yO" }, "source": [ "Now you can create a new notebook.\n", "\n", "\n", "* Check that the `pip program` is installed on your machine. For that, you just type `pip` into a console. Then, type these commands into your console:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 289 }, "colab_type": "code", "id": "_-wtSmeGM59a", "outputId": "c16886e4-4c6e-45bd-d0d8-6adf6c82cd88" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (1.1.0)\n", "Requirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python3.6/dist-packages (from scipy) (1.14.6)\n", "Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (1.14.6)\n", "Requirement already satisfied: matplotlib in /usr/local/lib/python3.6/dist-packages (3.0.3)\n", "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib) (1.0.1)\n", "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib) (0.10.0)\n", "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib) (2.5.3)\n", "Requirement already satisfied: numpy>=1.10.0 in /usr/local/lib/python3.6/dist-packages (from matplotlib) (1.14.6)\n", "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib) (2.3.1)\n", "Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from kiwisolver>=1.0.1->matplotlib) (40.8.0)\n", "Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from cycler>=0.10->matplotlib) (1.11.0)\n", "Requirement already satisfied: pandas in /usr/local/lib/python3.6/dist-packages (0.22.0)\n", "Requirement already satisfied: numpy>=1.9.0 in /usr/local/lib/python3.6/dist-packages (from pandas) (1.14.6)\n", "Requirement already satisfied: pytz>=2011k in /usr/local/lib/python3.6/dist-packages (from pandas) (2018.9)\n", "Requirement already satisfied: python-dateutil>=2 in /usr/local/lib/python3.6/dist-packages (from pandas) (2.5.3)\n", "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/dist-packages (from python-dateutil>=2->pandas) (1.11.0)\n" ] } ], "source": [ " !pip install scipy\n", " !pip install numpy\n", " !pip install matplotlib\n", " !pip install pandas" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "nobVMi-aNEMh" }, "source": [ "As an alternative, you can test Jupyter now, without installing anything via [this link](https://jupyter.org/try).\n", "\n", "Let us do our first experiment in a Jupyter notebook:\n", "\n", "To create a new notebook, click on `New` from the main Jupyter window and then on `Python 3`, like this:\n", "\n", "![create a new notebook](https://i.ibb.co/dWDfrwV/ju1.jpg)\n", "\n", "In the directory from which you started Jupyter, a file named `Untitled.ipynb` has normally been created.\n", "All Python commands must be typed in the field beside the `In [ ]` label. To do this, simply type several instructions simultaneously. Functions can even be defined. All variables produced in each cell will be accessible in all cells of the notebook. When you are finished entering them, press `Shift+Enter` to execute them.\n", "\n", "To test it, type for example `2 + 5` in the empty cell located in the center of the window. Then click on this button:\n", "![Test](https://i.ibb.co/0VQWxHS/2.jpg)\n", "\n", "### 2. Get started with Python\n", "\n", "In this section, we remember the basics of Python programming. In addition, we will not make a list of everything we need to master, but we will simulate a whole problem. Well, we first heard about the [Monty Hall problem](https://www.montyhallproblem.com/). The game involves a presenter against a competitor (the player). This player is positioned in front of three closed doors. There is a car behind one of them and a goat behind each of the others. First, it must indicate a door. Then the presenter must open a door that is neither the one chosen by the candidate nor the one hiding the car. The competitor then has the right to open the door or he initially chose, or to open the third door.\n", "\n", "\n", "First of all, let's set up our workspace in a notebook:" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "_MWPLDtrNOS2" }, "outputs": [], "source": [ "# For displaying graphics in the code sequence, \n", "# and not in a separate window:\n", "%matplotlib inline\n", "\n", "# By using the randint function, which generates numbers\n", "# whole in a random way:\n", "from random import randint, seed\n", "\n", "# An Enum is a data structure that consists of a \n", "# set of appointed elements. This type of variable can be\n", "# have as value one of these elements.\n", "from enum import Enum\n", "\n", "# For displaying graphs:\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "nZwquF_zNgwt" }, "source": [ "Here we define a subclass of Enum that will contain the possible strategies. This code involves the use of object-oriented programming concepts, including classes and heritages. " ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "nvdScfJWNhau" }, "outputs": [], "source": [ "class Strategy(Enum):\n", " CHANGE = 1\n", " KEEP = 2" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "BplRPuL5NkSK" }, "source": [ "It is possible to define our function. We will create a very simple function. It only represents a part of the game for a particular strategy. " ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "KoOiSdLiNmdw" }, "outputs": [], "source": [ "# Uses the system clock to initialize the generator of \n", "# pseudo-random numbers.\n", "seed()\n", "\n", "def Hall_game(strategy):\n", " ''' Simulates part of the Monty Hall game. This function simulates the participant's choice of door, the elimination of a bad door by the presenter, and the final choice. It only returns the result of the game, because that we will only need the result to perform our calculations.\n", " \n", " Args:\n", " strategy (strategy): The player's strategy\n", " \n", " Returns:\n", " bool: Has the player won?\n", " '''\n", " doors =[0, 1, 2]\n", " \n", " good_door = randint(0,2)\n", " \n", " # Choice of player\n", " first_choice = randint(0,2)\n", " \n", " # We have two doors left\n", " doors.remove(first_choice)\n", " \n", " # The presenter eliminates a door\n", " if first_choice == good_door:\n", " doors.remove(doors[randint(0,1)])\n", " else:\n", " doors =[good_door]\n", " \n", " second_choice = 0\n", " # The second choice depends on the strategy\n", " if strategy == Strategy.CHANGE:\n", " second_choice = doors[0]\n", " elif strategy == Strategy.KEEP:\n", " second_choice = first_choice\n", " else:\n", " raise ValueError(\"Strategy not recognized!\")\n", " \n", " return second_choice == good_door" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "SNl8XXn8NtQB" }, "source": [ "`Randint` function returns a random integer between its two arguments. For example, randint(0,1) will return 0 or 1. \n", "\n", "We will now test our function. Run the next line several times to make sure the result is random." ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 299 }, "colab_type": "code", "id": "nfy76TSTNvXV", "outputId": "bba613d8-cdd6-4588-fb08-bdad3d5c4ab5" }, "outputs": [ { "ename": "ValueError", "evalue": "ignored", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mHall_game\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mStrategy\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m\u001b[0m in \u001b[0;36mHall_game\u001b[0;34m(strategy)\u001b[0m\n\u001b[1;32m 33\u001b[0m \u001b[0msecond_choice\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfirst_choice\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 34\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 35\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Strategy not recognized!\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 36\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 37\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0msecond_choice\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mgood_door\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mValueError\u001b[0m: Strategy not recognized!" ] } ], "source": [ "Hall_game(Strategy)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "GFrftRwlQOSS" }, "source": [ "In this case, it will be necessary to define a function that will launch the game over and over again, and return the result of each game in a `list`.\n", "\n", "In order to make calculations on these results, we will no longer keep them as Boolean variables (True or False) but according to the player's victory (1 if he has won, 0 if he has lost)." ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "-9TACrxTQPzj" }, "outputs": [], "source": [ "def Play(strategy, nb_turns):\n", " '''Simulates a sequence of game turns. This function returns the results of several games of the Monty Hall game in the form of a list of winnings by the player.\n", " \n", " Args:\n", " strategy (strategy): The player's strategy\n", " nb_turns (int): Number of revolutions\n", " \n", " Returns:\n", " list: List of players' winnings for each game\n", " '''\n", "\n", " return [1 if Hall_game(strategy) else 0 for i in range(nb_turns)]" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "yZU-_k6YQdyx" }, "source": [ "For a given number of games (10000), it is first necessary to know which strategy is the most effective for the player. We have a list containing up to 1 as the number of games won by the player. It is just necessary to calculate the sum of all the items in this list, with the `sum function`, to know the number of 1." ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 51 }, "colab_type": "code", "id": "0_BXVfgIQhQZ", "outputId": "dbf105d0-fbbb-4866-be6f-e2ab1c953c9c" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "By changing doors, the player has won 6661 on 10,000 games.\n", "By keeping his initial choice, the player has won 3369 out of 10,000 games.\n" ] } ], "source": [ "print(\"By changing doors, the player has won {} on 10,000 games.\"\n", " .format(sum(Play(Strategy.CHANGE, 10000))))\n", " \n", "print(\"By keeping his initial choice, the player has won {} out of 10,000 games.\"\n", " .format(sum(Play(Strategy.KEEP, 10000))))" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "LTrEp2ELQxf3" }, "source": [ "### 3. Manipulate data using Numpy and Matplotlib\n", "\n", "**3.1. Manipulate data using Numpy**\n", "\n", "This section will focus on how to efficiently load, store and manipulate data. They can be found in a wide variety of sources, but they can always be considered as arrays of numbers. We' re going to see a tool to manipulate these arrays: Numpy. NumPy (Numerical Python) provides an interface to store and process data. Numpy arrays are like Python lists, but Numpy allows to make things much more efficient, especially for larger arrays.\n", "\n", "Let's start by importing Numpy:" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "zneWztcTQyF5" }, "outputs": [], "source": [ "import numpy as np\n" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "AJTzKGKdQ1BV" }, "source": [ "**Creating Numpy arrays**\n", "\n", "Numpy arrays, unlike Python lists, can only contain one type of members. There are several ways to create arrays in Numpy:" ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "colab_type": "code", "id": "UaOceLg1Q7nP", "outputId": "8306ea43-8866-4191-c62e-882ac84e78b6" }, "outputs": [ { "data": { "text/plain": [ "array([1, 2, 3])" ] }, "execution_count": 45, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "# Array of integers:\n", "np.array([1, 2, 3])" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "KuT4455wQ-6i" }, "source": [ "In case there are different types of data in the starting list, Numpy will try to convert them all to the most generic type. For example, integers `int` will be converted to `float` numbers:" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "colab_type": "code", "id": "sSMQDcypRDhy", "outputId": "5e3d0734-4440-48d2-a679-0cdf23a70a91" }, "outputs": [ { "data": { "text/plain": [ "array([3.1, 4. , 5. , 6. ])" ] }, "execution_count": 46, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "np.array([3.1, 4, 5, 6])" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "zWMIeEjLRElp" }, "source": [ "As an alternative, it is also possible to manually set a type:" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "colab_type": "code", "id": "0mZYyk1oRGkE", "outputId": "d509cfd2-2d73-4662-99d4-8a299cc70518" }, "outputs": [ { "data": { "text/plain": [ "array([1., 2., 3.], dtype=float32)" ] }, "execution_count": 47, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "np.array([1, 2, 3], dtype='float32')" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "M8KjB1MjRJMq" }, "source": [ "In many instances, it is more effective, particularly for large arrays, by creating them directly. Numpy has several functions for this task:" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 68 }, "colab_type": "code", "id": "PKSRzj29RMlL", "outputId": "3ecdcb7e-a7c3-4619-9a50-6c93f7130602" }, "outputs": [ { "data": { "text/plain": [ "array([[1., 0., 0.],\n", " [0., 1., 0.],\n", " [0., 0., 1.]])" ] }, "execution_count": 49, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "# An array of length 10, filled with integers that are worth 0\n", "np.zeros(10, dtype=int)\n", "\n", "# A 3x5 size array filled with floating point numbers of value 1\n", "np.ones((3, 5), dtype=float)\n", "\n", "# A 3x5 table filled with 3.14\n", "np.full((3, 5), 3.14)\n", "\n", "# A table filled with a linear sequence\n", "# starting from 0 and ending from 20, with a step of 2\n", "np.arange(0, 20, 2)\n", "\n", "# A table of 5 values, uniformly spaced between 0 and 1\n", "np.linspace(0, 1, 5)\n", "\n", "# This one you already know! Try also \"randint\" and \"normal\"\n", "#np.random((3, 3))\n", "\n", "# The identity matrix size 3x3 \n", "np.eye(3)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "zLe8-RkmRaZy" }, "source": [ "**Array properties, Indexation and Slicing**\n", "\n", "Each Numpy array has some properties that are often useful." ] }, { "cell_type": "code", "execution_count": 50, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 85 }, "colab_type": "code", "id": "ix_cPObPRdFu", "outputId": "46a1a17d-1748-4328-f1ef-1a2059f4e522" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dimensions number of x1: 1\n", "shape of x1: (6,)\n", "size of x1: 6\n", "type of x1: int64\n" ] } ], "source": [ "np.random.seed(0)\n", "x1 = np.random.randint(10, size=6) # Dimension table 1\n", "print(\"dimensions number of x1:\", x1.ndim)\n", "print(\"shape of x1:\", x1.shape)\n", "print(\"size of x1:\", x1.size)\n", "print(\"type of x1:\", x1.dtype)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "QdpuA9SNRgl-" }, "source": [ "In order to do this, we will often need to access one or more elements of a array. " ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 119 }, "colab_type": "code", "id": "P7AbMQJhRivJ", "outputId": "81c5931f-ff87-42af-e8e7-7ce4b27748f3" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[5 0 3 3 7 9]\n", "5\n", "9\n", "5\n", "[ 5 1000 3 3 7 9]\n", "[5 3 3 3 7 9]\n" ] } ], "source": [ "print(x1)\n", "\n", "# To get access to the first element\n", "print(x1[0])\n", "\n", "# to get access to the last element\n", "print(x1[-1])\n", "\n", "x2 = np.random.randint(10, size=(3, 4)) # Dimension table of 2\n", "print(x2[0,1])\n", "\n", "# We can also set different values\n", "x1[1] = \"1000\"\n", "print(x1)\n", "\n", "x1[1] = 3.14\n", "print(x1)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "liX0prIARmVi" }, "source": [ "In the same way that we can index elements using `[]`, we can access to a set of elements by combining `[]` and `:`. There is a simple rule for syntax: `x[start:end:step]`." ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 68 }, "colab_type": "code", "id": "PaZYbOG6Rot9", "outputId": "c2202130-c3a7-482c-b12b-ce6d57d0fffa" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[5 3 3 3 7]\n", "[9]\n", "[5 3 7]\n" ] } ], "source": [ "print(x1[:5]) # The first five elements\n", "\n", "print(x1[5:]) # Elements starting at index 5\n", "\n", "print(x1[::2]) # One of two elements" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "Poor6AWnRri_" }, "source": [ "Two or more arrays can be concatenated:" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "colab_type": "code", "id": "hdXtfGdMRtl0", "outputId": "f58ec1b8-24ad-427e-a279-3764c5dd01b8" }, "outputs": [ { "data": { "text/plain": [ "array([1, 2, 3, 3, 2, 1])" ] }, "execution_count": 53, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "x = np.array([1, 2, 3])\n", "y = np.array([3, 2, 1])\n", "np.concatenate([x, y])" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "HcMlwxroRw1a" }, "source": [ "So far, we have seen very basic things on Numpy arrays. Starting from here, we'll see what makes Numpy really essential. The benchmark implementation of Python, also called CPython, is very flexible, but this flexibility makes it unable to use all the possible optimizations." ] }, { "cell_type": "code", "execution_count": 54, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "colab_type": "code", "id": "SVunc4lGRy8K", "outputId": "42f550af-baf4-40f9-e58f-586fe49d4c7c" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0.11111111 0.5 0.16666667 0.11111111 0.2 ]\n" ] } ], "source": [ "def reverse_calculation(values):\n", " output = np.empty(len(values))\n", " for i in range(len(values)):\n", " output[i] = 1.0 / values[i]\n", " return output\n", " \n", "values = np.random.randint(1, 10, size=5)\n", "print(reverse_calculation(values))\n", "\n", "wide_array = np.random.randint(1, 100, size=1000000)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "Qyo3lqRMR15u" }, "source": [ "We now provide an overview of such operations:" ] }, { "cell_type": "code", "execution_count": 55, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 119 }, "colab_type": "code", "id": "mIwFRfWcR4He", "outputId": "87c423c3-5af1-4447-e840-be0528b6f3c5" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x = [0 1 2 3]\n", "x + 5 = [5 6 7 8]\n", "x - 5 = [-5 -4 -3 -2]\n", "x * 2 = [0 2 4 6]\n", "x / 2 = [0. 0.5 1. 1.5]\n", "x // 2 = [0 0 1 1]\n" ] } ], "source": [ "# First of all, there are simple mathematical operations\n", "x = np.arange(4)\n", "print(\"x =\", x)\n", "print(\"x + 5 =\", x + 5)\n", "print(\"x - 5 =\", x - 5)\n", "print(\"x * 2 =\", x * 2)\n", "print(\"x / 2 =\", x / 2)\n", "print(\"x // 2 =\", x // 2) " ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "gOhq-mtQR_Rk" }, "source": [ "Alternatively, you can also call functions on Numpy arrays, and even on Python lists." ] }, { "cell_type": "code", "execution_count": 58, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 68 }, "colab_type": "code", "id": "xYL_PAT5SBNg", "outputId": "1c7de189-e9de-4a8b-ffdd-8f4881bb58f2" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Absolute value: [6 3 2 5]\n", "Exponential: [2.47875218e-03 4.97870684e-02 7.38905610e+00 1.48413159e+02]\n", "Logarithm: [1.79175947 1.09861229 0.69314718 1.60943791]\n" ] } ], "source": [ "x = [-6, -3, 2, 5]\n", "print(\"Absolute value:\", np.abs(x))\n", "print(\"Exponential:\", np.exp(x))\n", "print(\"Logarithm:\", np.log(np.abs(x)))" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "r_HOMXA0SK7B" }, "source": [ "You can also execute Boolean operations on your arrays:" ] }, { "cell_type": "code", "execution_count": 59, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 85 }, "colab_type": "code", "id": "z5PuqE6-SNaO", "outputId": "43c29e4f-4a3b-4389-bc71-7f1def033eb4" }, "outputs": [ { "data": { "text/plain": [ "array([[ True, True, False, True],\n", " [ True, False, False, False],\n", " [False, False, False, False],\n", " [False, True, False, False]])" ] }, "execution_count": 59, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "x = np.random.rand(4,4)\n", "x > 0.7" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "XG99GF20SQTb" }, "source": [ "Numpy has functions to sum up these data on his arrays:" ] }, { "cell_type": "code", "execution_count": 60, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "colab_type": "code", "id": "lgbTOOL4SSeK", "outputId": "8817aecd-3f69-4675-ea87-34cda2928a45" }, "outputs": [ { "data": { "text/plain": [ "4.698357490059848" ] }, "execution_count": 60, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "L = np.random.random(10)\n", "np.sum(L)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "g6gzsAFDSWYn" }, "source": [ "**3.2. Manipulate data using Matplotlib**\n", "\n", "Matplotlib was created to generate graphics directly from Python. In this section, we focus on using Matplotlib as a visualization tool in Jupyter notebooks.\n", "\n", "To begin the process, let's set up the workspace:" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "YEWMt8RPSZY2" }, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "plt.style.use('seaborn-whitegrid')\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "zezABqrkScrf" }, "source": [ "Let's start by examining a simple case-like drawing the curve of a `sin` function:" ] }, { "cell_type": "code", "execution_count": 62, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 265 }, "colab_type": "code", "id": "uccZjDF_Seo4", "outputId": "0486a3bf-3ecf-4967-b9e1-d23747ba82b8" }, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3XlcVPe9+P/XmRmGfZdhEVREFEVR\nQETFLUZjYpo0bTVqqkl7821umuY2/f1Mr/na3mseNzFLH/U2zW1uszTpYtuUmpjUmFSz4Q6ioGwu\nICqy7yLIOjDfPxASowQcZubM8n4+HnmEWc6c94c5vjnnfT6LYjKZTAghhHAJGrUDEEIIYTuS9IUQ\nwoVI0hdCCBciSV8IIVyIJH0hhHAhOrUDGE5OTo7aIQghhENKTk6+4Tm7T/pw88BHIicnx+xtHZW0\n2TW4Wptdrb0w+jYPdcIs5R0hhHAhkvSFEMKFSNIXQggXIklfCCFciCR9IYRwIaNK+sXFxSxbtow/\n//nPN7x25MgRVq1axZo1a3jllVcGn3/uuedYs2YNa9euJT8/fzS7F0IIcYvM7rLZ3t7OM888w7x5\n8276+rPPPsubb75JaGgo69evZ8WKFTQ1NVFWVkZ6ejqlpaVs3ryZ9PR0s4MXQghxa8xO+nq9njfe\neIM33njjhtfKy8vx9/cnPDwcgM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78eo9HI008/\nrXZIVlFYWMiLL75IZWUlOp2OvXv38stf/pKnnnqK9PR0IiIiuO+++yyyL5laWQghXIhznyYIIYS4\njiR9IYRwIZL0hRDChUjSF0IIFyJJXwghXIgkfSGEcCGS9IUQwoX8PwxWM7eG755lAAAAAElFTkSu\nQmCC\n", "text/plain": [ "
" ] }, "metadata": { "tags": [] }, "output_type": "display_data" } ], "source": [ "fig = plt.figure()\n", "ax = plt.axes()\n", "x = np.linspace(0, 10, 1000)\n", "ax.plot(x, np.sin(x));" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "7IqEfDb4Si5P" }, "source": [ "he `fig` variable refers to a container that contains all items (axes, labels, data, etc.). The axes match the square shown above, which will then contain the data from the graph.\n", "\n", "\n", "In the case of discrete datasets (points), we frequently use error bars to represent, for each point, the incertitude as to its exact value:" ] }, { "cell_type": "code", "execution_count": 63, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 265 }, "colab_type": "code", "id": "09iO8hbDSluo", "outputId": "51ef4bbb-e7ed-40a1-92ba-42e9661951fd" }, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAD4CAYAAADmWv3KAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3X1wVNXdB/DvZsOCIREaZAkMbQOU\nN0NoTUwhZhIwBcHMxGolE3B4qaLYEbUvAcrQF5gBQag6rcoMQkFLmLEZwD+k02kcp3GGSoS4OJQw\nLVEZMAQKWbTKusDu3eT5I0+2m82+3pe995z7/cwww+bu3nvO3rO/e+55u47e3t5eEBGRdLLMTgAR\nERmDAZ6ISFIM8EREkmKAJyKSFAM8EZGkss1OQD+Px2N2EoiIhFRaWhrz75oC/I4dO+DxeKAoCp58\n8kncd9994W3Hjh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te/sHbt2gHnQe9zInQN3u12\nw+v1hl9fvXoVo0ePNjFF6o2EXq5AAAAB1ElEQVQZMwY1NTVwOBz41re+hTvuuANXrlwxO1ma5OTk\n4ObNmwCAK1euCN3kUV5ejunTpwMAqqur0dHRYXKKUnP06FHs2rULe/bsQV5entDnJDovIp6T9vZ2\nXL58GQAwffp0hEIhDB8+3LBzInSAr6ioQHNzMwDgzJkzcLvdyM3NNTlV6rz99tvYu3cvAKC7uxvX\nrl3DmDFjTE6VNvfcc0/4/LzzzjuorKw0OUXqPfPMM+js7ATQ17fQP9rJyq5fv44dO3bgtddeC480\nEfWcxMqLiOfkww8/xL59+wD0NTH7/X5Dz4nwq0m+8MIL+PDDD+FwOLBx40ZMmzbN7CSp4vP5sGbN\nGnz11VcIBoN4+umnMWfOHLOTlbL29nZs374dXV1dyM7OxpgxY/DCCy9g/fr1uHXrFsaNG4dt27Zh\nyJAhZic1qVh5Wbp0KXbv3o3bbrsNOTk52LZtG0aNGmV2UhNqamrCK6+8ggkTJoT/9vzzz+PXv/61\ncOckVl5+9KMf4cCBA0Kdk5s3b+JXv/oVLl++jJs3b+Lpp5/GjBkz8Mtf/tKQcyJ8gCciotiEbqIh\nIqL4GOCJiCTFAE9EJCkGeCIiSTHAExFJigGeiEhSDPBERJL6P+5G9ZN5tDddAAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": { "tags": [] }, "output_type": "display_data" } ], "source": [ "x = np.linspace(0, 30, 80)\n", "dy = 0.3\n", "y = np.sin(x) + dy * np.random.randn(80)\n", "\n", "plt.errorbar(x, y, yerr=dy, fmt='.k');" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "P5RZ30ScSoWM" }, "source": [ "### 4. Deal with a large amount of data using Pandas library\n", "\n", "\n", "The Pandas library is one of the basic libraries for data science in Python. Pandas offers easy-to-use and robust data structures and the means to use them quickly. In this section, we will discuss what is of interest to the Pandas library, as well as the basic operations on the main object of this library, the `Dataframe`.\n", "\n", "This pandas can be represented by a numpy array:\n" ] }, { "cell_type": "code", "execution_count": 64, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "colab_type": "code", "id": "1tzoSgueSrA6", "outputId": "ae0af486-a14d-42f7-fd5e-e214dd21d8e1" }, "outputs": [ { "data": { "text/plain": [ "array([200, 50, 100, 80])" ] }, "execution_count": 64, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "import numpy as np\n", "panda_numpy = np.array([200,50,100,80])\n", "panda_numpy" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "h92pbZcLSuFS" }, "source": [ "It is possible to do this:" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "BjkfVMrsSwCx" }, "outputs": [], "source": [ "family = [\n", " np.array([100, 5, 20, 80]), # mom \n", " np.array([50, 2.5, 10, 40]), # baby \n", " np.array([110, 6, 22, 80]), # daddy \n", "]" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "ftbgk7TbSz1O" }, "source": [ "Let's represent the `family` with Pandas:" ] }, { "cell_type": "code", "execution_count": 67, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 142 }, "colab_type": "code", "id": "pJDW2v14S1vd", "outputId": "67323e32-7806-4625-ea54-59d5a16a057c" }, "outputs": [ { "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", "
0123
0100.05.020.080.0
150.02.510.040.0
2110.06.022.080.0
\n", "
" ], "text/plain": [ " 0 1 2 3\n", "0 100.0 5.0 20.0 80.0\n", "1 50.0 2.5 10.0 40.0\n", "2 110.0 6.0 22.0 80.0" ] }, "execution_count": 67, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "family_df = pd.DataFrame(family)\n", "family_df" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "WBTvQb0ES7mN" }, "source": [ "The object that can be used to represent arrays is the `DataFrame` object\n", "\n", "In fact, we can do even better, by specifying column names and row names:" ] }, { "cell_type": "code", "execution_count": 70, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 142 }, "colab_type": "code", "id": "wNwohKggS-ha", "outputId": "4b09b61d-8f2b-4b49-b7f0-19455fb7db4d" }, "outputs": [ { "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", "
legshairhandsbelly
mom100.05.020.080.0
baby50.02.510.040.0
dad110.06.022.080.0
\n", "
" ], "text/plain": [ " legs hair hands belly\n", "mom 100.0 5.0 20.0 80.0\n", "baby 50.0 2.5 10.0 40.0\n", "dad 110.0 6.0 22.0 80.0" ] }, "execution_count": 70, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "family_df = pd.DataFrame(family,\n", " index = ['mom','baby','dad'],\n", " columns = ['legs','hair','hands','belly'])\n", "family_df" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "VINRsHjhTMAU" }, "source": [ "Here are some of the little features of Dataframes. Firstly, to access to belly column of our array. There are two possible syntaxes, which return exactly the same result:" ] }, { "cell_type": "code", "execution_count": 71, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 85 }, "colab_type": "code", "id": "NhtOaX-CTOOv", "outputId": "39ccf429-5fb3-497a-ab6b-54f46788b760" }, "outputs": [ { "data": { "text/plain": [ "mom 80.0\n", "baby 40.0\n", "dad 80.0\n", "Name: belly, dtype: float64" ] }, "execution_count": 71, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "family_df.belly\n", "family_df[\"belly\"]" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "_fBmFYgMTREr" }, "source": [ " We will now see the whole family one by one, via the `iterrows` method by returning a tuple that has as its first element the index and the content of the line:" ] }, { "cell_type": "code", "execution_count": 72, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 323 }, "colab_type": "code", "id": "Z9BIOR9WTTkH", "outputId": "b75f5bde-5f08-463b-8e6b-c003676d0249" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Family: mom :\n", "legs 100.0\n", "hair 5.0\n", "hands 20.0\n", "belly 80.0\n", "Name: mom, dtype: float64\n", "Family: baby :\n", "legs 50.0\n", "hair 2.5\n", "hands 10.0\n", "belly 40.0\n", "Name: baby, dtype: float64\n", "Family: dad :\n", "legs 110.0\n", "hair 6.0\n", "hands 22.0\n", "belly 80.0\n", "Name: dad, dtype: float64\n" ] } ], "source": [ "for ind, content in family_df.iterrows():\n", " print(\"Family: %s :\" % ind)\n", " print(content)" ] }, { "cell_type": "code", "execution_count": 74, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "colab_type": "code", "id": "H9eHMwNST868", "outputId": "e8ca042a-8ce0-4256-ebc8-8727490382fd" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Writing dataset.csv\n" ] } ], "source": [ "# Create a CSV file called dataset\n", "\n", "%%writefile dataset.csv\n", "John,Doe,120 jefferson st.,Riverside, NJ, 08075\n", "Jack,McGinnis,220 hobo Av.,Phila, PA,09119\n", "\"John \"\"Da Man\"\"\",Repici,120 Jefferson St.,Riverside, NJ,08075\n", "Stephen,Tyler,\"7452 Terrace \"\"At the Plaza\"\" road\",SomeTown,SD, 91234\n", ",Blankman,,SomeTown, SD, 00298\n", "\"Joan \"\"the bone\"\", Anne\",Jet,\"9th, at Terrace plc\",Desert City,CO,00123" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "ntXXjrp9TXA_" }, "source": [ "The Pandas library is the one that is pointed in the manipulation of arrays. It is therefore possible to read a CSV file with Pandas: it only takes one line to create a dataframe from a CSV:" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "rVirXOQdTZPy" }, "outputs": [], "source": [ "data = pd.read_csv(\"dataset.csv\", sep=\";\")" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "mbop7pxoTjGa" }, "source": [ "* The `data` variable now contains a dataframe containing the data from the csv file;\n", "* The values in our CSV file are separated by the symbol `;` ;\n", "* As a default, `pd.read_csv` expects values that are separated by a comma" ] } ], "metadata": { "colab": { "collapsed_sections": [], "name": "PythonDataScience", "provenance": [], "toc_visible": true, "version": "0.3.2" }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.1" } }, "nbformat": 4, "nbformat_minor": 1 }