{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!DOCTYPE html>\n",
    "<html>\n",
    "<body>\n",
    "<div align=\"center\">\n",
    "<h3>Prepared by Asif Bhat</h3>\n",
    "    \n",
    "<h1>Data Visualization With Seaborn</h1>\n",
    "\n",
    "<h3>Follow Me on - <a href=\"https://www.linkedin.com/in/asif-bhat/\">LinkedIn</a>&nbsp; <a href=\"https://mobile.twitter.com/_asifbhat_\">Twitter</a>&nbsp; <a href=\"https://www.instagram.com/datasciencescoop/?hl=en\">Instagram</a>&nbsp; <a href=\"https://www.facebook.com/datasciencescoop/\">Facebook</a></h3>\n",
    "\n",
    "</div>\n",
    "</body>\n",
    "</html>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 674,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import matplotlib as mpl"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Loading Datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 675,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>#</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type 1</th>\n",
       "      <th>Type 2</th>\n",
       "      <th>HP</th>\n",
       "      <th>Attack</th>\n",
       "      <th>Defense</th>\n",
       "      <th>Sp. Atk</th>\n",
       "      <th>Sp. Def</th>\n",
       "      <th>Speed</th>\n",
       "      <th>Generation</th>\n",
       "      <th>Legendary</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Bulbasaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>45</td>\n",
       "      <td>49</td>\n",
       "      <td>49</td>\n",
       "      <td>65</td>\n",
       "      <td>65</td>\n",
       "      <td>45</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>318</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Ivysaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>60</td>\n",
       "      <td>62</td>\n",
       "      <td>63</td>\n",
       "      <td>80</td>\n",
       "      <td>80</td>\n",
       "      <td>60</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Venusaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>80</td>\n",
       "      <td>82</td>\n",
       "      <td>83</td>\n",
       "      <td>100</td>\n",
       "      <td>100</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>525</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>VenusaurMega Venusaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>80</td>\n",
       "      <td>100</td>\n",
       "      <td>123</td>\n",
       "      <td>122</td>\n",
       "      <td>120</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>Charmander</td>\n",
       "      <td>Fire</td>\n",
       "      <td>NaN</td>\n",
       "      <td>39</td>\n",
       "      <td>52</td>\n",
       "      <td>43</td>\n",
       "      <td>60</td>\n",
       "      <td>50</td>\n",
       "      <td>65</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>309</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5</td>\n",
       "      <td>Charmeleon</td>\n",
       "      <td>Fire</td>\n",
       "      <td>NaN</td>\n",
       "      <td>58</td>\n",
       "      <td>64</td>\n",
       "      <td>58</td>\n",
       "      <td>80</td>\n",
       "      <td>65</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>6</td>\n",
       "      <td>Charizard</td>\n",
       "      <td>Fire</td>\n",
       "      <td>Flying</td>\n",
       "      <td>78</td>\n",
       "      <td>84</td>\n",
       "      <td>78</td>\n",
       "      <td>109</td>\n",
       "      <td>85</td>\n",
       "      <td>100</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>534</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>6</td>\n",
       "      <td>CharizardMega Charizard X</td>\n",
       "      <td>Fire</td>\n",
       "      <td>Dragon</td>\n",
       "      <td>78</td>\n",
       "      <td>130</td>\n",
       "      <td>111</td>\n",
       "      <td>130</td>\n",
       "      <td>85</td>\n",
       "      <td>100</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>634</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>6</td>\n",
       "      <td>CharizardMega Charizard Y</td>\n",
       "      <td>Fire</td>\n",
       "      <td>Flying</td>\n",
       "      <td>78</td>\n",
       "      <td>104</td>\n",
       "      <td>78</td>\n",
       "      <td>159</td>\n",
       "      <td>115</td>\n",
       "      <td>100</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>634</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>7</td>\n",
       "      <td>Squirtle</td>\n",
       "      <td>Water</td>\n",
       "      <td>NaN</td>\n",
       "      <td>44</td>\n",
       "      <td>48</td>\n",
       "      <td>65</td>\n",
       "      <td>50</td>\n",
       "      <td>64</td>\n",
       "      <td>43</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>314</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   #                       Name Type 1  Type 2  HP  Attack  Defense  Sp. Atk  \\\n",
       "0  1                  Bulbasaur  Grass  Poison  45      49       49       65   \n",
       "1  2                    Ivysaur  Grass  Poison  60      62       63       80   \n",
       "2  3                   Venusaur  Grass  Poison  80      82       83      100   \n",
       "3  3      VenusaurMega Venusaur  Grass  Poison  80     100      123      122   \n",
       "4  4                 Charmander   Fire     NaN  39      52       43       60   \n",
       "5  5                 Charmeleon   Fire     NaN  58      64       58       80   \n",
       "6  6                  Charizard   Fire  Flying  78      84       78      109   \n",
       "7  6  CharizardMega Charizard X   Fire  Dragon  78     130      111      130   \n",
       "8  6  CharizardMega Charizard Y   Fire  Flying  78     104       78      159   \n",
       "9  7                   Squirtle  Water     NaN  44      48       65       50   \n",
       "\n",
       "   Sp. Def  Speed  Generation  Legendary  Total  \n",
       "0       65     45           1      False    318  \n",
       "1       80     60           1      False    405  \n",
       "2      100     80           1      False    525  \n",
       "3      120     80           1      False    625  \n",
       "4       50     65           1      False    309  \n",
       "5       65     80           1      False    405  \n",
       "6       85    100           1      False    534  \n",
       "7       85    100           1      False    634  \n",
       "8      115    100           1      False    634  \n",
       "9       64     43           1      False    314  "
      ]
     },
     "execution_count": 675,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pokemon = pd.read_csv(\"pokemon_updated.csv\")\n",
    "pokemon.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 676,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gender</th>\n",
       "      <th>race/ethnicity</th>\n",
       "      <th>parental level of education</th>\n",
       "      <th>lunch</th>\n",
       "      <th>test preparation course</th>\n",
       "      <th>math score</th>\n",
       "      <th>reading score</th>\n",
       "      <th>writing score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>bachelor's degree</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>72</td>\n",
       "      <td>72</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>female</td>\n",
       "      <td>group C</td>\n",
       "      <td>some college</td>\n",
       "      <td>standard</td>\n",
       "      <td>completed</td>\n",
       "      <td>69</td>\n",
       "      <td>90</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>master's degree</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>90</td>\n",
       "      <td>95</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>male</td>\n",
       "      <td>group A</td>\n",
       "      <td>associate's degree</td>\n",
       "      <td>free/reduced</td>\n",
       "      <td>none</td>\n",
       "      <td>47</td>\n",
       "      <td>57</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>male</td>\n",
       "      <td>group C</td>\n",
       "      <td>some college</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>76</td>\n",
       "      <td>78</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>associate's degree</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>71</td>\n",
       "      <td>83</td>\n",
       "      <td>78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>some college</td>\n",
       "      <td>standard</td>\n",
       "      <td>completed</td>\n",
       "      <td>88</td>\n",
       "      <td>95</td>\n",
       "      <td>92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>male</td>\n",
       "      <td>group B</td>\n",
       "      <td>some college</td>\n",
       "      <td>free/reduced</td>\n",
       "      <td>none</td>\n",
       "      <td>40</td>\n",
       "      <td>43</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>male</td>\n",
       "      <td>group D</td>\n",
       "      <td>high school</td>\n",
       "      <td>free/reduced</td>\n",
       "      <td>completed</td>\n",
       "      <td>64</td>\n",
       "      <td>64</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>high school</td>\n",
       "      <td>free/reduced</td>\n",
       "      <td>none</td>\n",
       "      <td>38</td>\n",
       "      <td>60</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   gender race/ethnicity parental level of education         lunch  \\\n",
       "0  female        group B           bachelor's degree      standard   \n",
       "1  female        group C                some college      standard   \n",
       "2  female        group B             master's degree      standard   \n",
       "3    male        group A          associate's degree  free/reduced   \n",
       "4    male        group C                some college      standard   \n",
       "5  female        group B          associate's degree      standard   \n",
       "6  female        group B                some college      standard   \n",
       "7    male        group B                some college  free/reduced   \n",
       "8    male        group D                 high school  free/reduced   \n",
       "9  female        group B                 high school  free/reduced   \n",
       "\n",
       "  test preparation course  math score  reading score  writing score  \n",
       "0                    none          72             72             74  \n",
       "1               completed          69             90             88  \n",
       "2                    none          90             95             93  \n",
       "3                    none          47             57             44  \n",
       "4                    none          76             78             75  \n",
       "5                    none          71             83             78  \n",
       "6               completed          88             95             92  \n",
       "7                    none          40             43             39  \n",
       "8               completed          64             64             67  \n",
       "9                    none          38             60             50  "
      ]
     },
     "execution_count": 676,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stdperf = pd.read_csv(\"studentp.csv\")\n",
    "stdperf.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 677,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>Confirmed</th>\n",
       "      <th>Recovered</th>\n",
       "      <th>Deaths</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Albania</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Algeria</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Andorra</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Angola</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Antigua and Barbuda</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Argentina</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Armenia</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Australia</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Austria</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        Country  Confirmed  Recovered  Deaths\n",
       "Date                                                         \n",
       "2020-01-22          Afghanistan          0          0       0\n",
       "2020-01-22              Albania          0          0       0\n",
       "2020-01-22              Algeria          0          0       0\n",
       "2020-01-22              Andorra          0          0       0\n",
       "2020-01-22               Angola          0          0       0\n",
       "2020-01-22  Antigua and Barbuda          0          0       0\n",
       "2020-01-22            Argentina          0          0       0\n",
       "2020-01-22              Armenia          0          0       0\n",
       "2020-01-22            Australia          0          0       0\n",
       "2020-01-22              Austria          0          0       0"
      ]
     },
     "execution_count": 677,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corona = pd.read_csv('C:/Users/DELL/Documents/GitHub/Public/COVID-19/covid/data/countries-aggregated.csv' ,\n",
    "                     index_col='Date' , parse_dates=True)\n",
    "corona.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 678,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Shape of You</th>\n",
       "      <th>Despacito</th>\n",
       "      <th>Something Just Like This</th>\n",
       "      <th>HUMBLE.</th>\n",
       "      <th>Unforgettable</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-01-06</th>\n",
       "      <td>12287078</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-07</th>\n",
       "      <td>13190270</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-08</th>\n",
       "      <td>13099919</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-09</th>\n",
       "      <td>14506351</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-10</th>\n",
       "      <td>14275628</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-11</th>\n",
       "      <td>14372699</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-12</th>\n",
       "      <td>14148108</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-13</th>\n",
       "      <td>14536236</td>\n",
       "      <td>275178.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-14</th>\n",
       "      <td>14173311</td>\n",
       "      <td>1144886.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-15</th>\n",
       "      <td>12889849</td>\n",
       "      <td>1288198.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Shape of You  Despacito  Something Just Like This  HUMBLE.  \\\n",
       "Date                                                                     \n",
       "2017-01-06      12287078        NaN                       NaN      NaN   \n",
       "2017-01-07      13190270        NaN                       NaN      NaN   \n",
       "2017-01-08      13099919        NaN                       NaN      NaN   \n",
       "2017-01-09      14506351        NaN                       NaN      NaN   \n",
       "2017-01-10      14275628        NaN                       NaN      NaN   \n",
       "2017-01-11      14372699        NaN                       NaN      NaN   \n",
       "2017-01-12      14148108        NaN                       NaN      NaN   \n",
       "2017-01-13      14536236   275178.0                       NaN      NaN   \n",
       "2017-01-14      14173311  1144886.0                       NaN      NaN   \n",
       "2017-01-15      12889849  1288198.0                       NaN      NaN   \n",
       "\n",
       "            Unforgettable  \n",
       "Date                       \n",
       "2017-01-06            NaN  \n",
       "2017-01-07            NaN  \n",
       "2017-01-08            NaN  \n",
       "2017-01-09            NaN  \n",
       "2017-01-10            NaN  \n",
       "2017-01-11            NaN  \n",
       "2017-01-12            NaN  \n",
       "2017-01-13            NaN  \n",
       "2017-01-14            NaN  \n",
       "2017-01-15            NaN  "
      ]
     },
     "execution_count": 678,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "spotify = pd.read_csv(\"spotify.csv\" , index_col=\"Date\")\n",
    "spotify.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 679,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>longitude</th>\n",
       "      <th>latitude</th>\n",
       "      <th>housing_median_age</th>\n",
       "      <th>total_rooms</th>\n",
       "      <th>total_bedrooms</th>\n",
       "      <th>population</th>\n",
       "      <th>households</th>\n",
       "      <th>median_income</th>\n",
       "      <th>median_house_value</th>\n",
       "      <th>ocean_proximity</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20635</th>\n",
       "      <td>-121.09</td>\n",
       "      <td>39.48</td>\n",
       "      <td>25.0</td>\n",
       "      <td>1665.0</td>\n",
       "      <td>374.0</td>\n",
       "      <td>845.0</td>\n",
       "      <td>330.0</td>\n",
       "      <td>1.5603</td>\n",
       "      <td>78100.0</td>\n",
       "      <td>INLAND</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20636</th>\n",
       "      <td>-121.21</td>\n",
       "      <td>39.49</td>\n",
       "      <td>18.0</td>\n",
       "      <td>697.0</td>\n",
       "      <td>150.0</td>\n",
       "      <td>356.0</td>\n",
       "      <td>114.0</td>\n",
       "      <td>2.5568</td>\n",
       "      <td>77100.0</td>\n",
       "      <td>INLAND</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20637</th>\n",
       "      <td>-121.22</td>\n",
       "      <td>39.43</td>\n",
       "      <td>17.0</td>\n",
       "      <td>2254.0</td>\n",
       "      <td>485.0</td>\n",
       "      <td>1007.0</td>\n",
       "      <td>433.0</td>\n",
       "      <td>1.7000</td>\n",
       "      <td>92300.0</td>\n",
       "      <td>INLAND</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20638</th>\n",
       "      <td>-121.32</td>\n",
       "      <td>39.43</td>\n",
       "      <td>18.0</td>\n",
       "      <td>1860.0</td>\n",
       "      <td>409.0</td>\n",
       "      <td>741.0</td>\n",
       "      <td>349.0</td>\n",
       "      <td>1.8672</td>\n",
       "      <td>84700.0</td>\n",
       "      <td>INLAND</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20639</th>\n",
       "      <td>-121.24</td>\n",
       "      <td>39.37</td>\n",
       "      <td>16.0</td>\n",
       "      <td>2785.0</td>\n",
       "      <td>616.0</td>\n",
       "      <td>1387.0</td>\n",
       "      <td>530.0</td>\n",
       "      <td>2.3886</td>\n",
       "      <td>89400.0</td>\n",
       "      <td>INLAND</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       longitude  latitude  housing_median_age  total_rooms  total_bedrooms  \\\n",
       "20635    -121.09     39.48                25.0       1665.0           374.0   \n",
       "20636    -121.21     39.49                18.0        697.0           150.0   \n",
       "20637    -121.22     39.43                17.0       2254.0           485.0   \n",
       "20638    -121.32     39.43                18.0       1860.0           409.0   \n",
       "20639    -121.24     39.37                16.0       2785.0           616.0   \n",
       "\n",
       "       population  households  median_income  median_house_value  \\\n",
       "20635       845.0       330.0         1.5603             78100.0   \n",
       "20636       356.0       114.0         2.5568             77100.0   \n",
       "20637      1007.0       433.0         1.7000             92300.0   \n",
       "20638       741.0       349.0         1.8672             84700.0   \n",
       "20639      1387.0       530.0         2.3886             89400.0   \n",
       "\n",
       "      ocean_proximity  \n",
       "20635          INLAND  \n",
       "20636          INLAND  \n",
       "20637          INLAND  \n",
       "20638          INLAND  \n",
       "20639          INLAND  "
      ]
     },
     "execution_count": 679,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "housing = pd.read_csv('C:/Users/DELL/Documents/GitHub/Data-Visualization/housing.csv')\n",
    "housing.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 680,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>sex</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>smoker</th>\n",
       "      <th>region</th>\n",
       "      <th>charges</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "      <td>southwest</td>\n",
       "      <td>16884.92400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>1725.55230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>male</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>4449.46200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>male</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>21984.47061</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>male</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>3866.85520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>31</td>\n",
       "      <td>female</td>\n",
       "      <td>25.740</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>3756.62160</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>46</td>\n",
       "      <td>female</td>\n",
       "      <td>33.440</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>8240.58960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>37</td>\n",
       "      <td>female</td>\n",
       "      <td>27.740</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>7281.50560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>37</td>\n",
       "      <td>male</td>\n",
       "      <td>29.830</td>\n",
       "      <td>2</td>\n",
       "      <td>no</td>\n",
       "      <td>northeast</td>\n",
       "      <td>6406.41070</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>60</td>\n",
       "      <td>female</td>\n",
       "      <td>25.840</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>28923.13692</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     sex     bmi  children smoker     region      charges\n",
       "0   19  female  27.900         0    yes  southwest  16884.92400\n",
       "1   18    male  33.770         1     no  southeast   1725.55230\n",
       "2   28    male  33.000         3     no  southeast   4449.46200\n",
       "3   33    male  22.705         0     no  northwest  21984.47061\n",
       "4   32    male  28.880         0     no  northwest   3866.85520\n",
       "5   31  female  25.740         0     no  southeast   3756.62160\n",
       "6   46  female  33.440         1     no  southeast   8240.58960\n",
       "7   37  female  27.740         3     no  northwest   7281.50560\n",
       "8   37    male  29.830         2     no  northeast   6406.41070\n",
       "9   60  female  25.840         0     no  northwest  28923.13692"
      ]
     },
     "execution_count": 680,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insurance = pd.read_csv('C:/Users/DELL/Documents/GitHub/Data-Visualization/insurance.csv')\n",
    "insurance.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 681,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Period</th>\n",
       "      <th>Unemployed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>16 to 19 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>91000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20 to 24 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>175000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>25 to 34 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>194000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>35 to 44 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>201000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>207000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>55 to 64 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>101000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>65 years and over</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>33000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>16 to 19 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>38000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>20 to 24 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>90000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>25 to 34 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>142000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 Age Gender     Period  Unemployed\n",
       "0     16 to 19 years    Men 2005-01-01       91000\n",
       "1     20 to 24 years    Men 2005-01-01      175000\n",
       "2     25 to 34 years    Men 2005-01-01      194000\n",
       "3     35 to 44 years    Men 2005-01-01      201000\n",
       "4     45 to 54 years    Men 2005-01-01      207000\n",
       "5     55 to 64 years    Men 2005-01-01      101000\n",
       "6  65 years and over    Men 2005-01-01       33000\n",
       "7     16 to 19 years  Women 2005-01-01       38000\n",
       "8     20 to 24 years  Women 2005-01-01       90000\n",
       "9     25 to 34 years  Women 2005-01-01      142000"
      ]
     },
     "execution_count": 681,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employment = pd.read_excel(\"unemployment.xlsx\")\n",
    "employment.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 683,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ticket</th>\n",
       "      <th>requestor</th>\n",
       "      <th>RequestorSeniority</th>\n",
       "      <th>ITOwner</th>\n",
       "      <th>FiledAgainst</th>\n",
       "      <th>TicketType</th>\n",
       "      <th>Severity</th>\n",
       "      <th>Priority</th>\n",
       "      <th>daysOpen</th>\n",
       "      <th>Satisfaction</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1929</td>\n",
       "      <td>1 - Junior</td>\n",
       "      <td>50</td>\n",
       "      <td>Systems</td>\n",
       "      <td>Issue</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>3</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1587</td>\n",
       "      <td>2 - Regular</td>\n",
       "      <td>15</td>\n",
       "      <td>Software</td>\n",
       "      <td>Request</td>\n",
       "      <td>1 - Minor</td>\n",
       "      <td>1 - Low</td>\n",
       "      <td>5</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>925</td>\n",
       "      <td>2 - Regular</td>\n",
       "      <td>15</td>\n",
       "      <td>Access/Login</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>0</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>413</td>\n",
       "      <td>4 - Management</td>\n",
       "      <td>22</td>\n",
       "      <td>Systems</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>20</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>318</td>\n",
       "      <td>1 - Junior</td>\n",
       "      <td>22</td>\n",
       "      <td>Access/Login</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>1 - Low</td>\n",
       "      <td>1</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>858</td>\n",
       "      <td>4 - Management</td>\n",
       "      <td>38</td>\n",
       "      <td>Access/Login</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>3 - High</td>\n",
       "      <td>0</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>1978</td>\n",
       "      <td>3 - Senior</td>\n",
       "      <td>10</td>\n",
       "      <td>Systems</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>3 - High</td>\n",
       "      <td>9</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>1209</td>\n",
       "      <td>4 - Management</td>\n",
       "      <td>1</td>\n",
       "      <td>Software</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>15</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>887</td>\n",
       "      <td>2 - Regular</td>\n",
       "      <td>14</td>\n",
       "      <td>Software</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>2 - Medium</td>\n",
       "      <td>6</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>1780</td>\n",
       "      <td>3 - Senior</td>\n",
       "      <td>46</td>\n",
       "      <td>Access/Login</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>1 - Low</td>\n",
       "      <td>1</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ticket  requestor RequestorSeniority  ITOwner  FiledAgainst TicketType  \\\n",
       "0       1       1929         1 - Junior       50       Systems      Issue   \n",
       "1       2       1587        2 - Regular       15      Software    Request   \n",
       "2       3        925        2 - Regular       15  Access/Login    Request   \n",
       "3       4        413     4 - Management       22       Systems    Request   \n",
       "4       5        318         1 - Junior       22  Access/Login    Request   \n",
       "5       6        858     4 - Management       38  Access/Login    Request   \n",
       "6       7       1978         3 - Senior       10       Systems    Request   \n",
       "7       8       1209     4 - Management        1      Software    Request   \n",
       "8       9        887        2 - Regular       14      Software    Request   \n",
       "9      10       1780         3 - Senior       46  Access/Login    Request   \n",
       "\n",
       "     Severity        Priority  daysOpen     Satisfaction  \n",
       "0  2 - Normal  0 - Unassigned         3  1 - Unsatisfied  \n",
       "1   1 - Minor         1 - Low         5  1 - Unsatisfied  \n",
       "2  2 - Normal  0 - Unassigned         0      0 - Unknown  \n",
       "3  2 - Normal  0 - Unassigned        20      0 - Unknown  \n",
       "4  2 - Normal         1 - Low         1  1 - Unsatisfied  \n",
       "5  2 - Normal        3 - High         0      0 - Unknown  \n",
       "6  2 - Normal        3 - High         9      0 - Unknown  \n",
       "7  2 - Normal  0 - Unassigned        15      0 - Unknown  \n",
       "8  2 - Normal      2 - Medium         6  1 - Unsatisfied  \n",
       "9  2 - Normal         1 - Low         1  1 - Unsatisfied  "
      ]
     },
     "execution_count": 683,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "helpdesk = pd.read_csv(\"helpdesk.csv\")\n",
    "helpdesk.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 684,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Species</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Length1</th>\n",
       "      <th>Length2</th>\n",
       "      <th>Length3</th>\n",
       "      <th>Height</th>\n",
       "      <th>Width</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Bream</td>\n",
       "      <td>242.0</td>\n",
       "      <td>23.2</td>\n",
       "      <td>25.4</td>\n",
       "      <td>30.0</td>\n",
       "      <td>11.5200</td>\n",
       "      <td>4.0200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Bream</td>\n",
       "      <td>290.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>26.3</td>\n",
       "      <td>31.2</td>\n",
       "      <td>12.4800</td>\n",
       "      <td>4.3056</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Bream</td>\n",
       "      <td>340.0</td>\n",
       "      <td>23.9</td>\n",
       "      <td>26.5</td>\n",
       "      <td>31.1</td>\n",
       "      <td>12.3778</td>\n",
       "      <td>4.6961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Bream</td>\n",
       "      <td>363.0</td>\n",
       "      <td>26.3</td>\n",
       "      <td>29.0</td>\n",
       "      <td>33.5</td>\n",
       "      <td>12.7300</td>\n",
       "      <td>4.4555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Bream</td>\n",
       "      <td>430.0</td>\n",
       "      <td>26.5</td>\n",
       "      <td>29.0</td>\n",
       "      <td>34.0</td>\n",
       "      <td>12.4440</td>\n",
       "      <td>5.1340</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Bream</td>\n",
       "      <td>450.0</td>\n",
       "      <td>26.8</td>\n",
       "      <td>29.7</td>\n",
       "      <td>34.7</td>\n",
       "      <td>13.6024</td>\n",
       "      <td>4.9274</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Bream</td>\n",
       "      <td>500.0</td>\n",
       "      <td>26.8</td>\n",
       "      <td>29.7</td>\n",
       "      <td>34.5</td>\n",
       "      <td>14.1795</td>\n",
       "      <td>5.2785</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Bream</td>\n",
       "      <td>390.0</td>\n",
       "      <td>27.6</td>\n",
       "      <td>30.0</td>\n",
       "      <td>35.0</td>\n",
       "      <td>12.6700</td>\n",
       "      <td>4.6900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Bream</td>\n",
       "      <td>450.0</td>\n",
       "      <td>27.6</td>\n",
       "      <td>30.0</td>\n",
       "      <td>35.1</td>\n",
       "      <td>14.0049</td>\n",
       "      <td>4.8438</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Bream</td>\n",
       "      <td>500.0</td>\n",
       "      <td>28.5</td>\n",
       "      <td>30.7</td>\n",
       "      <td>36.2</td>\n",
       "      <td>14.2266</td>\n",
       "      <td>4.9594</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Species  Weight  Length1  Length2  Length3   Height   Width\n",
       "0   Bream   242.0     23.2     25.4     30.0  11.5200  4.0200\n",
       "1   Bream   290.0     24.0     26.3     31.2  12.4800  4.3056\n",
       "2   Bream   340.0     23.9     26.5     31.1  12.3778  4.6961\n",
       "3   Bream   363.0     26.3     29.0     33.5  12.7300  4.4555\n",
       "4   Bream   430.0     26.5     29.0     34.0  12.4440  5.1340\n",
       "5   Bream   450.0     26.8     29.7     34.7  13.6024  4.9274\n",
       "6   Bream   500.0     26.8     29.7     34.5  14.1795  5.2785\n",
       "7   Bream   390.0     27.6     30.0     35.0  12.6700  4.6900\n",
       "8   Bream   450.0     27.6     30.0     35.1  14.0049  4.8438\n",
       "9   Bream   500.0     28.5     30.7     36.2  14.2266  4.9594"
      ]
     },
     "execution_count": 684,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fish= pd.read_csv(\"Fish.csv\")\n",
    "fish.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 685,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>diet</th>\n",
       "      <th>pulse</th>\n",
       "      <th>time</th>\n",
       "      <th>kind</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>85</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>85</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>88</td>\n",
       "      <td>30 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>90</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>92</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>93</td>\n",
       "      <td>30 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>3</td>\n",
       "      <td>low fat</td>\n",
       "      <td>97</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>3</td>\n",
       "      <td>low fat</td>\n",
       "      <td>97</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>3</td>\n",
       "      <td>low fat</td>\n",
       "      <td>94</td>\n",
       "      <td>30 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>4</td>\n",
       "      <td>low fat</td>\n",
       "      <td>80</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id     diet  pulse    time  kind\n",
       "0   1  low fat     85   1 min  rest\n",
       "1   1  low fat     85  15 min  rest\n",
       "2   1  low fat     88  30 min  rest\n",
       "3   2  low fat     90   1 min  rest\n",
       "4   2  low fat     92  15 min  rest\n",
       "5   2  low fat     93  30 min  rest\n",
       "6   3  low fat     97   1 min  rest\n",
       "7   3  low fat     97  15 min  rest\n",
       "8   3  low fat     94  30 min  rest\n",
       "9   4  low fat     80   1 min  rest"
      ]
     },
     "execution_count": 685,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "exercise = pd.read_csv(\"exercise.csv\")\n",
    "exercise.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 686,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>year</th>\n",
       "      <th>sex</th>\n",
       "      <th>age</th>\n",
       "      <th>suicides_no</th>\n",
       "      <th>population</th>\n",
       "      <th>suicides/100k pop</th>\n",
       "      <th>country-year</th>\n",
       "      <th>HDI for year</th>\n",
       "      <th>gdp_for_year ($)</th>\n",
       "      <th>gdp_per_capita ($)</th>\n",
       "      <th>generation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1987</td>\n",
       "      <td>male</td>\n",
       "      <td>15-24 years</td>\n",
       "      <td>21</td>\n",
       "      <td>312900</td>\n",
       "      <td>6.71</td>\n",
       "      <td>Albania1987</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2,156,624,900</td>\n",
       "      <td>796</td>\n",
       "      <td>Generation X</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1987</td>\n",
       "      <td>male</td>\n",
       "      <td>35-54 years</td>\n",
       "      <td>16</td>\n",
       "      <td>308000</td>\n",
       "      <td>5.19</td>\n",
       "      <td>Albania1987</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2,156,624,900</td>\n",
       "      <td>796</td>\n",
       "      <td>Silent</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1987</td>\n",
       "      <td>female</td>\n",
       "      <td>15-24 years</td>\n",
       "      <td>14</td>\n",
       "      <td>289700</td>\n",
       "      <td>4.83</td>\n",
       "      <td>Albania1987</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2,156,624,900</td>\n",
       "      <td>796</td>\n",
       "      <td>Generation X</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1987</td>\n",
       "      <td>male</td>\n",
       "      <td>75+ years</td>\n",
       "      <td>1</td>\n",
       "      <td>21800</td>\n",
       "      <td>4.59</td>\n",
       "      <td>Albania1987</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2,156,624,900</td>\n",
       "      <td>796</td>\n",
       "      <td>G.I. Generation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1987</td>\n",
       "      <td>male</td>\n",
       "      <td>25-34 years</td>\n",
       "      <td>9</td>\n",
       "      <td>274300</td>\n",
       "      <td>3.28</td>\n",
       "      <td>Albania1987</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2,156,624,900</td>\n",
       "      <td>796</td>\n",
       "      <td>Boomers</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1987</td>\n",
       "      <td>female</td>\n",
       "      <td>75+ years</td>\n",
       "      <td>1</td>\n",
       "      <td>35600</td>\n",
       "      <td>2.81</td>\n",
       "      <td>Albania1987</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2,156,624,900</td>\n",
       "      <td>796</td>\n",
       "      <td>G.I. Generation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1987</td>\n",
       "      <td>female</td>\n",
       "      <td>35-54 years</td>\n",
       "      <td>6</td>\n",
       "      <td>278800</td>\n",
       "      <td>2.15</td>\n",
       "      <td>Albania1987</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2,156,624,900</td>\n",
       "      <td>796</td>\n",
       "      <td>Silent</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1987</td>\n",
       "      <td>female</td>\n",
       "      <td>25-34 years</td>\n",
       "      <td>4</td>\n",
       "      <td>257200</td>\n",
       "      <td>1.56</td>\n",
       "      <td>Albania1987</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2,156,624,900</td>\n",
       "      <td>796</td>\n",
       "      <td>Boomers</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1987</td>\n",
       "      <td>male</td>\n",
       "      <td>55-74 years</td>\n",
       "      <td>1</td>\n",
       "      <td>137500</td>\n",
       "      <td>0.73</td>\n",
       "      <td>Albania1987</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2,156,624,900</td>\n",
       "      <td>796</td>\n",
       "      <td>G.I. Generation</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1987</td>\n",
       "      <td>female</td>\n",
       "      <td>5-14 years</td>\n",
       "      <td>0</td>\n",
       "      <td>311000</td>\n",
       "      <td>0.00</td>\n",
       "      <td>Albania1987</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2,156,624,900</td>\n",
       "      <td>796</td>\n",
       "      <td>Generation X</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   country  year     sex          age  suicides_no  population  \\\n",
       "0  Albania  1987    male  15-24 years           21      312900   \n",
       "1  Albania  1987    male  35-54 years           16      308000   \n",
       "2  Albania  1987  female  15-24 years           14      289700   \n",
       "3  Albania  1987    male    75+ years            1       21800   \n",
       "4  Albania  1987    male  25-34 years            9      274300   \n",
       "5  Albania  1987  female    75+ years            1       35600   \n",
       "6  Albania  1987  female  35-54 years            6      278800   \n",
       "7  Albania  1987  female  25-34 years            4      257200   \n",
       "8  Albania  1987    male  55-74 years            1      137500   \n",
       "9  Albania  1987  female   5-14 years            0      311000   \n",
       "\n",
       "   suicides/100k pop country-year  HDI for year  gdp_for_year ($)   \\\n",
       "0               6.71  Albania1987           NaN      2,156,624,900   \n",
       "1               5.19  Albania1987           NaN      2,156,624,900   \n",
       "2               4.83  Albania1987           NaN      2,156,624,900   \n",
       "3               4.59  Albania1987           NaN      2,156,624,900   \n",
       "4               3.28  Albania1987           NaN      2,156,624,900   \n",
       "5               2.81  Albania1987           NaN      2,156,624,900   \n",
       "6               2.15  Albania1987           NaN      2,156,624,900   \n",
       "7               1.56  Albania1987           NaN      2,156,624,900   \n",
       "8               0.73  Albania1987           NaN      2,156,624,900   \n",
       "9               0.00  Albania1987           NaN      2,156,624,900   \n",
       "\n",
       "   gdp_per_capita ($)       generation  \n",
       "0                 796     Generation X  \n",
       "1                 796           Silent  \n",
       "2                 796     Generation X  \n",
       "3                 796  G.I. Generation  \n",
       "4                 796          Boomers  \n",
       "5                 796  G.I. Generation  \n",
       "6                 796           Silent  \n",
       "7                 796          Boomers  \n",
       "8                 796  G.I. Generation  \n",
       "9                 796     Generation X  "
      ]
     },
     "execution_count": 686,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "suicide = pd.read_csv(\"suicide.csv\") \n",
    "suicide.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 687,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Type</th>\n",
       "      <th>Coverage</th>\n",
       "      <th>OdName</th>\n",
       "      <th>AREA</th>\n",
       "      <th>AreaName</th>\n",
       "      <th>REG</th>\n",
       "      <th>RegName</th>\n",
       "      <th>DEV</th>\n",
       "      <th>DevName</th>\n",
       "      <th>1980</th>\n",
       "      <th>...</th>\n",
       "      <th>2004</th>\n",
       "      <th>2005</th>\n",
       "      <th>2006</th>\n",
       "      <th>2007</th>\n",
       "      <th>2008</th>\n",
       "      <th>2009</th>\n",
       "      <th>2010</th>\n",
       "      <th>2011</th>\n",
       "      <th>2012</th>\n",
       "      <th>2013</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Immigrants</td>\n",
       "      <td>Foreigners</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>935</td>\n",
       "      <td>Asia</td>\n",
       "      <td>5501</td>\n",
       "      <td>Southern Asia</td>\n",
       "      <td>902</td>\n",
       "      <td>Developing regions</td>\n",
       "      <td>16</td>\n",
       "      <td>...</td>\n",
       "      <td>2978</td>\n",
       "      <td>3436</td>\n",
       "      <td>3009</td>\n",
       "      <td>2652</td>\n",
       "      <td>2111</td>\n",
       "      <td>1746</td>\n",
       "      <td>1758</td>\n",
       "      <td>2203</td>\n",
       "      <td>2635</td>\n",
       "      <td>2004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Immigrants</td>\n",
       "      <td>Foreigners</td>\n",
       "      <td>Albania</td>\n",
       "      <td>908</td>\n",
       "      <td>Europe</td>\n",
       "      <td>925</td>\n",
       "      <td>Southern Europe</td>\n",
       "      <td>901</td>\n",
       "      <td>Developed regions</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1450</td>\n",
       "      <td>1223</td>\n",
       "      <td>856</td>\n",
       "      <td>702</td>\n",
       "      <td>560</td>\n",
       "      <td>716</td>\n",
       "      <td>561</td>\n",
       "      <td>539</td>\n",
       "      <td>620</td>\n",
       "      <td>603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Immigrants</td>\n",
       "      <td>Foreigners</td>\n",
       "      <td>Algeria</td>\n",
       "      <td>903</td>\n",
       "      <td>Africa</td>\n",
       "      <td>912</td>\n",
       "      <td>Northern Africa</td>\n",
       "      <td>902</td>\n",
       "      <td>Developing regions</td>\n",
       "      <td>80</td>\n",
       "      <td>...</td>\n",
       "      <td>3616</td>\n",
       "      <td>3626</td>\n",
       "      <td>4807</td>\n",
       "      <td>3623</td>\n",
       "      <td>4005</td>\n",
       "      <td>5393</td>\n",
       "      <td>4752</td>\n",
       "      <td>4325</td>\n",
       "      <td>3774</td>\n",
       "      <td>4331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Immigrants</td>\n",
       "      <td>Foreigners</td>\n",
       "      <td>American Samoa</td>\n",
       "      <td>909</td>\n",
       "      <td>Oceania</td>\n",
       "      <td>957</td>\n",
       "      <td>Polynesia</td>\n",
       "      <td>902</td>\n",
       "      <td>Developing regions</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Immigrants</td>\n",
       "      <td>Foreigners</td>\n",
       "      <td>Andorra</td>\n",
       "      <td>908</td>\n",
       "      <td>Europe</td>\n",
       "      <td>925</td>\n",
       "      <td>Southern Europe</td>\n",
       "      <td>901</td>\n",
       "      <td>Developed regions</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 43 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Type    Coverage          OdName  AREA AreaName   REG  \\\n",
       "0  Immigrants  Foreigners     Afghanistan   935     Asia  5501   \n",
       "1  Immigrants  Foreigners         Albania   908   Europe   925   \n",
       "2  Immigrants  Foreigners         Algeria   903   Africa   912   \n",
       "3  Immigrants  Foreigners  American Samoa   909  Oceania   957   \n",
       "4  Immigrants  Foreigners         Andorra   908   Europe   925   \n",
       "\n",
       "           RegName  DEV             DevName  1980  ...   2004  2005  2006  \\\n",
       "0    Southern Asia  902  Developing regions    16  ...   2978  3436  3009   \n",
       "1  Southern Europe  901   Developed regions     1  ...   1450  1223   856   \n",
       "2  Northern Africa  902  Developing regions    80  ...   3616  3626  4807   \n",
       "3        Polynesia  902  Developing regions     0  ...      0     0     1   \n",
       "4  Southern Europe  901   Developed regions     0  ...      0     0     1   \n",
       "\n",
       "   2007  2008  2009  2010  2011  2012  2013  \n",
       "0  2652  2111  1746  1758  2203  2635  2004  \n",
       "1   702   560   716   561   539   620   603  \n",
       "2  3623  4005  5393  4752  4325  3774  4331  \n",
       "3     0     0     0     0     0     0     0  \n",
       "4     1     0     0     0     0     1     1  \n",
       "\n",
       "[5 rows x 43 columns]"
      ]
     },
     "execution_count": 687,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "canada = pd.read_csv(\"canada.csv\")\n",
    "canada.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 688,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Type', 'Coverage', 'OdName', 'AREA', 'AreaName', 'REG', 'RegName',\n",
       "       'DEV', 'DevName', '1980', '1981', '1982', '1983', '1984', '1985',\n",
       "       '1986', '1987', '1988', '1989', '1990', '1991', '1992', '1993', '1994',\n",
       "       '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003',\n",
       "       '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012',\n",
       "       '2013'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 688,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "canada.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 689,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>OdName</th>\n",
       "      <th>1980</th>\n",
       "      <th>1981</th>\n",
       "      <th>1982</th>\n",
       "      <th>1983</th>\n",
       "      <th>1984</th>\n",
       "      <th>1985</th>\n",
       "      <th>1986</th>\n",
       "      <th>1987</th>\n",
       "      <th>1988</th>\n",
       "      <th>...</th>\n",
       "      <th>2004</th>\n",
       "      <th>2005</th>\n",
       "      <th>2006</th>\n",
       "      <th>2007</th>\n",
       "      <th>2008</th>\n",
       "      <th>2009</th>\n",
       "      <th>2010</th>\n",
       "      <th>2011</th>\n",
       "      <th>2012</th>\n",
       "      <th>2013</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>16</td>\n",
       "      <td>39</td>\n",
       "      <td>39</td>\n",
       "      <td>47</td>\n",
       "      <td>71</td>\n",
       "      <td>340</td>\n",
       "      <td>496</td>\n",
       "      <td>741</td>\n",
       "      <td>828</td>\n",
       "      <td>...</td>\n",
       "      <td>2978</td>\n",
       "      <td>3436</td>\n",
       "      <td>3009</td>\n",
       "      <td>2652</td>\n",
       "      <td>2111</td>\n",
       "      <td>1746</td>\n",
       "      <td>1758</td>\n",
       "      <td>2203</td>\n",
       "      <td>2635</td>\n",
       "      <td>2004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>1450</td>\n",
       "      <td>1223</td>\n",
       "      <td>856</td>\n",
       "      <td>702</td>\n",
       "      <td>560</td>\n",
       "      <td>716</td>\n",
       "      <td>561</td>\n",
       "      <td>539</td>\n",
       "      <td>620</td>\n",
       "      <td>603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Algeria</td>\n",
       "      <td>80</td>\n",
       "      <td>67</td>\n",
       "      <td>71</td>\n",
       "      <td>69</td>\n",
       "      <td>63</td>\n",
       "      <td>44</td>\n",
       "      <td>69</td>\n",
       "      <td>132</td>\n",
       "      <td>242</td>\n",
       "      <td>...</td>\n",
       "      <td>3616</td>\n",
       "      <td>3626</td>\n",
       "      <td>4807</td>\n",
       "      <td>3623</td>\n",
       "      <td>4005</td>\n",
       "      <td>5393</td>\n",
       "      <td>4752</td>\n",
       "      <td>4325</td>\n",
       "      <td>3774</td>\n",
       "      <td>4331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>American Samoa</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Andorra</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           OdName  1980  1981  1982  1983  1984  1985  1986  1987  1988  ...   \\\n",
       "0     Afghanistan    16    39    39    47    71   340   496   741   828  ...    \n",
       "1         Albania     1     0     0     0     0     0     1     2     2  ...    \n",
       "2         Algeria    80    67    71    69    63    44    69   132   242  ...    \n",
       "3  American Samoa     0     1     0     0     0     0     0     1     0  ...    \n",
       "4         Andorra     0     0     0     0     0     0     2     0     0  ...    \n",
       "\n",
       "   2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  \n",
       "0  2978  3436  3009  2652  2111  1746  1758  2203  2635  2004  \n",
       "1  1450  1223   856   702   560   716   561   539   620   603  \n",
       "2  3616  3626  4807  3623  4005  5393  4752  4325  3774  4331  \n",
       "3     0     0     1     0     0     0     0     0     0     0  \n",
       "4     0     0     1     1     0     0     0     0     1     1  \n",
       "\n",
       "[5 rows x 35 columns]"
      ]
     },
     "execution_count": 689,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "canada.drop(columns=['AREA' , 'DEV', 'DevName' , 'REG', 'Type', 'Coverage' , 'AreaName', 'RegName' ], inplace=True)\n",
    "canada.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 690,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>1980</th>\n",
       "      <th>1981</th>\n",
       "      <th>1982</th>\n",
       "      <th>1983</th>\n",
       "      <th>1984</th>\n",
       "      <th>1985</th>\n",
       "      <th>1986</th>\n",
       "      <th>1987</th>\n",
       "      <th>1988</th>\n",
       "      <th>...</th>\n",
       "      <th>2004</th>\n",
       "      <th>2005</th>\n",
       "      <th>2006</th>\n",
       "      <th>2007</th>\n",
       "      <th>2008</th>\n",
       "      <th>2009</th>\n",
       "      <th>2010</th>\n",
       "      <th>2011</th>\n",
       "      <th>2012</th>\n",
       "      <th>2013</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Afghanistan</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>16</td>\n",
       "      <td>39</td>\n",
       "      <td>39</td>\n",
       "      <td>47</td>\n",
       "      <td>71</td>\n",
       "      <td>340</td>\n",
       "      <td>496</td>\n",
       "      <td>741</td>\n",
       "      <td>828</td>\n",
       "      <td>...</td>\n",
       "      <td>2978</td>\n",
       "      <td>3436</td>\n",
       "      <td>3009</td>\n",
       "      <td>2652</td>\n",
       "      <td>2111</td>\n",
       "      <td>1746</td>\n",
       "      <td>1758</td>\n",
       "      <td>2203</td>\n",
       "      <td>2635</td>\n",
       "      <td>2004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Albania</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>1450</td>\n",
       "      <td>1223</td>\n",
       "      <td>856</td>\n",
       "      <td>702</td>\n",
       "      <td>560</td>\n",
       "      <td>716</td>\n",
       "      <td>561</td>\n",
       "      <td>539</td>\n",
       "      <td>620</td>\n",
       "      <td>603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Algeria</th>\n",
       "      <td>Algeria</td>\n",
       "      <td>80</td>\n",
       "      <td>67</td>\n",
       "      <td>71</td>\n",
       "      <td>69</td>\n",
       "      <td>63</td>\n",
       "      <td>44</td>\n",
       "      <td>69</td>\n",
       "      <td>132</td>\n",
       "      <td>242</td>\n",
       "      <td>...</td>\n",
       "      <td>3616</td>\n",
       "      <td>3626</td>\n",
       "      <td>4807</td>\n",
       "      <td>3623</td>\n",
       "      <td>4005</td>\n",
       "      <td>5393</td>\n",
       "      <td>4752</td>\n",
       "      <td>4325</td>\n",
       "      <td>3774</td>\n",
       "      <td>4331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>American Samoa</th>\n",
       "      <td>American Samoa</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Andorra</th>\n",
       "      <td>Andorra</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       Country  1980  1981  1982  1983  1984  1985  1986  \\\n",
       "Country                                                                    \n",
       "Afghanistan        Afghanistan    16    39    39    47    71   340   496   \n",
       "Albania                Albania     1     0     0     0     0     0     1   \n",
       "Algeria                Algeria    80    67    71    69    63    44    69   \n",
       "American Samoa  American Samoa     0     1     0     0     0     0     0   \n",
       "Andorra                Andorra     0     0     0     0     0     0     2   \n",
       "\n",
       "                1987  1988  ...   2004  2005  2006  2007  2008  2009  2010  \\\n",
       "Country                     ...                                              \n",
       "Afghanistan      741   828  ...   2978  3436  3009  2652  2111  1746  1758   \n",
       "Albania            2     2  ...   1450  1223   856   702   560   716   561   \n",
       "Algeria          132   242  ...   3616  3626  4807  3623  4005  5393  4752   \n",
       "American Samoa     1     0  ...      0     0     1     0     0     0     0   \n",
       "Andorra            0     0  ...      0     0     1     1     0     0     0   \n",
       "\n",
       "                2011  2012  2013  \n",
       "Country                           \n",
       "Afghanistan     2203  2635  2004  \n",
       "Albania          539   620   603  \n",
       "Algeria         4325  3774  4331  \n",
       "American Samoa     0     0     0  \n",
       "Andorra            0     1     1  \n",
       "\n",
       "[5 rows x 35 columns]"
      ]
     },
     "execution_count": 690,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "canada.rename(columns={'OdName':'Country'} , inplace=True)\n",
    "canada.set_index(canada.Country,inplace=True)\n",
    "canada.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 691,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>1980</th>\n",
       "      <th>1981</th>\n",
       "      <th>1982</th>\n",
       "      <th>1983</th>\n",
       "      <th>1984</th>\n",
       "      <th>1985</th>\n",
       "      <th>1986</th>\n",
       "      <th>1987</th>\n",
       "      <th>1988</th>\n",
       "      <th>...</th>\n",
       "      <th>2004</th>\n",
       "      <th>2005</th>\n",
       "      <th>2006</th>\n",
       "      <th>2007</th>\n",
       "      <th>2008</th>\n",
       "      <th>2009</th>\n",
       "      <th>2010</th>\n",
       "      <th>2011</th>\n",
       "      <th>2012</th>\n",
       "      <th>2013</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Afghanistan</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>16</td>\n",
       "      <td>39</td>\n",
       "      <td>39</td>\n",
       "      <td>47</td>\n",
       "      <td>71</td>\n",
       "      <td>340</td>\n",
       "      <td>496</td>\n",
       "      <td>741</td>\n",
       "      <td>828</td>\n",
       "      <td>...</td>\n",
       "      <td>2978</td>\n",
       "      <td>3436</td>\n",
       "      <td>3009</td>\n",
       "      <td>2652</td>\n",
       "      <td>2111</td>\n",
       "      <td>1746</td>\n",
       "      <td>1758</td>\n",
       "      <td>2203</td>\n",
       "      <td>2635</td>\n",
       "      <td>2004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Albania</th>\n",
       "      <td>Albania</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>1450</td>\n",
       "      <td>1223</td>\n",
       "      <td>856</td>\n",
       "      <td>702</td>\n",
       "      <td>560</td>\n",
       "      <td>716</td>\n",
       "      <td>561</td>\n",
       "      <td>539</td>\n",
       "      <td>620</td>\n",
       "      <td>603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Algeria</th>\n",
       "      <td>Algeria</td>\n",
       "      <td>80</td>\n",
       "      <td>67</td>\n",
       "      <td>71</td>\n",
       "      <td>69</td>\n",
       "      <td>63</td>\n",
       "      <td>44</td>\n",
       "      <td>69</td>\n",
       "      <td>132</td>\n",
       "      <td>242</td>\n",
       "      <td>...</td>\n",
       "      <td>3616</td>\n",
       "      <td>3626</td>\n",
       "      <td>4807</td>\n",
       "      <td>3623</td>\n",
       "      <td>4005</td>\n",
       "      <td>5393</td>\n",
       "      <td>4752</td>\n",
       "      <td>4325</td>\n",
       "      <td>3774</td>\n",
       "      <td>4331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>American Samoa</th>\n",
       "      <td>American Samoa</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Andorra</th>\n",
       "      <td>Andorra</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       Country  1980  1981  1982  1983  1984  1985  1986  \\\n",
       "Afghanistan        Afghanistan    16    39    39    47    71   340   496   \n",
       "Albania                Albania     1     0     0     0     0     0     1   \n",
       "Algeria                Algeria    80    67    71    69    63    44    69   \n",
       "American Samoa  American Samoa     0     1     0     0     0     0     0   \n",
       "Andorra                Andorra     0     0     0     0     0     0     2   \n",
       "\n",
       "                1987  1988  ...   2004  2005  2006  2007  2008  2009  2010  \\\n",
       "Afghanistan      741   828  ...   2978  3436  3009  2652  2111  1746  1758   \n",
       "Albania            2     2  ...   1450  1223   856   702   560   716   561   \n",
       "Algeria          132   242  ...   3616  3626  4807  3623  4005  5393  4752   \n",
       "American Samoa     1     0  ...      0     0     1     0     0     0     0   \n",
       "Andorra            0     0  ...      0     0     1     1     0     0     0   \n",
       "\n",
       "                2011  2012  2013  \n",
       "Afghanistan     2203  2635  2004  \n",
       "Albania          539   620   603  \n",
       "Algeria         4325  3774  4331  \n",
       "American Samoa     0     0     0  \n",
       "Andorra            0     1     1  \n",
       "\n",
       "[5 rows x 35 columns]"
      ]
     },
     "execution_count": 691,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "canada.index.name=None\n",
    "canada.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 692,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>1980</th>\n",
       "      <th>1981</th>\n",
       "      <th>1982</th>\n",
       "      <th>1983</th>\n",
       "      <th>1984</th>\n",
       "      <th>1985</th>\n",
       "      <th>1986</th>\n",
       "      <th>1987</th>\n",
       "      <th>1988</th>\n",
       "      <th>1989</th>\n",
       "      <th>...</th>\n",
       "      <th>2004</th>\n",
       "      <th>2005</th>\n",
       "      <th>2006</th>\n",
       "      <th>2007</th>\n",
       "      <th>2008</th>\n",
       "      <th>2009</th>\n",
       "      <th>2010</th>\n",
       "      <th>2011</th>\n",
       "      <th>2012</th>\n",
       "      <th>2013</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Afghanistan</th>\n",
       "      <td>16</td>\n",
       "      <td>39</td>\n",
       "      <td>39</td>\n",
       "      <td>47</td>\n",
       "      <td>71</td>\n",
       "      <td>340</td>\n",
       "      <td>496</td>\n",
       "      <td>741</td>\n",
       "      <td>828</td>\n",
       "      <td>1076</td>\n",
       "      <td>...</td>\n",
       "      <td>2978</td>\n",
       "      <td>3436</td>\n",
       "      <td>3009</td>\n",
       "      <td>2652</td>\n",
       "      <td>2111</td>\n",
       "      <td>1746</td>\n",
       "      <td>1758</td>\n",
       "      <td>2203</td>\n",
       "      <td>2635</td>\n",
       "      <td>2004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Albania</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>...</td>\n",
       "      <td>1450</td>\n",
       "      <td>1223</td>\n",
       "      <td>856</td>\n",
       "      <td>702</td>\n",
       "      <td>560</td>\n",
       "      <td>716</td>\n",
       "      <td>561</td>\n",
       "      <td>539</td>\n",
       "      <td>620</td>\n",
       "      <td>603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Algeria</th>\n",
       "      <td>80</td>\n",
       "      <td>67</td>\n",
       "      <td>71</td>\n",
       "      <td>69</td>\n",
       "      <td>63</td>\n",
       "      <td>44</td>\n",
       "      <td>69</td>\n",
       "      <td>132</td>\n",
       "      <td>242</td>\n",
       "      <td>434</td>\n",
       "      <td>...</td>\n",
       "      <td>3616</td>\n",
       "      <td>3626</td>\n",
       "      <td>4807</td>\n",
       "      <td>3623</td>\n",
       "      <td>4005</td>\n",
       "      <td>5393</td>\n",
       "      <td>4752</td>\n",
       "      <td>4325</td>\n",
       "      <td>3774</td>\n",
       "      <td>4331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>American Samoa</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Andorra</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 34 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                1980  1981  1982  1983  1984  1985  1986  1987  1988  1989  \\\n",
       "Afghanistan       16    39    39    47    71   340   496   741   828  1076   \n",
       "Albania            1     0     0     0     0     0     1     2     2     3   \n",
       "Algeria           80    67    71    69    63    44    69   132   242   434   \n",
       "American Samoa     0     1     0     0     0     0     0     1     0     1   \n",
       "Andorra            0     0     0     0     0     0     2     0     0     0   \n",
       "\n",
       "                ...   2004  2005  2006  2007  2008  2009  2010  2011  2012  \\\n",
       "Afghanistan     ...   2978  3436  3009  2652  2111  1746  1758  2203  2635   \n",
       "Albania         ...   1450  1223   856   702   560   716   561   539   620   \n",
       "Algeria         ...   3616  3626  4807  3623  4005  5393  4752  4325  3774   \n",
       "American Samoa  ...      0     0     1     0     0     0     0     0     0   \n",
       "Andorra         ...      0     0     1     1     0     0     0     0     1   \n",
       "\n",
       "                2013  \n",
       "Afghanistan     2004  \n",
       "Albania          603  \n",
       "Algeria         4331  \n",
       "American Samoa     0  \n",
       "Andorra            1  \n",
       "\n",
       "[5 rows x 34 columns]"
      ]
     },
     "execution_count": 692,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "del canada['Country']\n",
    "canada.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 693,
   "metadata": {},
   "outputs": [],
   "source": [
    "canada = canada.transpose()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 694,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Afghanistan</th>\n",
       "      <th>Albania</th>\n",
       "      <th>Algeria</th>\n",
       "      <th>American Samoa</th>\n",
       "      <th>Andorra</th>\n",
       "      <th>Angola</th>\n",
       "      <th>Antigua and Barbuda</th>\n",
       "      <th>Argentina</th>\n",
       "      <th>Armenia</th>\n",
       "      <th>Australia</th>\n",
       "      <th>...</th>\n",
       "      <th>Uzbekistan</th>\n",
       "      <th>Vanuatu</th>\n",
       "      <th>Venezuela (Bolivarian Republic of)</th>\n",
       "      <th>Viet Nam</th>\n",
       "      <th>Western Sahara</th>\n",
       "      <th>Yemen</th>\n",
       "      <th>Zambia</th>\n",
       "      <th>Zimbabwe</th>\n",
       "      <th>Unknown</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1980</th>\n",
       "      <td>16</td>\n",
       "      <td>1</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>368</td>\n",
       "      <td>0</td>\n",
       "      <td>702</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>103</td>\n",
       "      <td>1191</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>11</td>\n",
       "      <td>72</td>\n",
       "      <td>44000</td>\n",
       "      <td>143137</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1981</th>\n",
       "      <td>39</td>\n",
       "      <td>0</td>\n",
       "      <td>67</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>426</td>\n",
       "      <td>0</td>\n",
       "      <td>639</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>117</td>\n",
       "      <td>1829</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>17</td>\n",
       "      <td>114</td>\n",
       "      <td>18078</td>\n",
       "      <td>128641</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1982</th>\n",
       "      <td>39</td>\n",
       "      <td>0</td>\n",
       "      <td>71</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>626</td>\n",
       "      <td>0</td>\n",
       "      <td>484</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>174</td>\n",
       "      <td>2162</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>11</td>\n",
       "      <td>102</td>\n",
       "      <td>16904</td>\n",
       "      <td>121175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1983</th>\n",
       "      <td>47</td>\n",
       "      <td>0</td>\n",
       "      <td>69</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>241</td>\n",
       "      <td>0</td>\n",
       "      <td>317</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>124</td>\n",
       "      <td>3404</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>44</td>\n",
       "      <td>13635</td>\n",
       "      <td>89185</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1984</th>\n",
       "      <td>71</td>\n",
       "      <td>0</td>\n",
       "      <td>63</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>42</td>\n",
       "      <td>237</td>\n",
       "      <td>0</td>\n",
       "      <td>317</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>142</td>\n",
       "      <td>7583</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>32</td>\n",
       "      <td>14855</td>\n",
       "      <td>88272</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 197 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Afghanistan  Albania  Algeria  American Samoa  Andorra  Angola  \\\n",
       "1980           16        1       80               0        0       1   \n",
       "1981           39        0       67               1        0       3   \n",
       "1982           39        0       71               0        0       6   \n",
       "1983           47        0       69               0        0       6   \n",
       "1984           71        0       63               0        0       4   \n",
       "\n",
       "      Antigua and Barbuda  Argentina  Armenia  Australia   ...    Uzbekistan  \\\n",
       "1980                    0        368        0        702   ...             0   \n",
       "1981                    0        426        0        639   ...             0   \n",
       "1982                    0        626        0        484   ...             0   \n",
       "1983                    0        241        0        317   ...             0   \n",
       "1984                   42        237        0        317   ...             0   \n",
       "\n",
       "      Vanuatu  Venezuela (Bolivarian Republic of)  Viet Nam  Western Sahara  \\\n",
       "1980        0                                 103      1191               0   \n",
       "1981        0                                 117      1829               0   \n",
       "1982        0                                 174      2162               0   \n",
       "1983        0                                 124      3404               0   \n",
       "1984        0                                 142      7583               0   \n",
       "\n",
       "      Yemen  Zambia  Zimbabwe  Unknown   Total  \n",
       "1980      1      11        72    44000  143137  \n",
       "1981      2      17       114    18078  128641  \n",
       "1982      1      11       102    16904  121175  \n",
       "1983      6       7        44    13635   89185  \n",
       "1984      0      16        32    14855   88272  \n",
       "\n",
       "[5 rows x 197 columns]"
      ]
     },
     "execution_count": 694,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "canada.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 695,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>Year</th>\n",
       "      <th>Status</th>\n",
       "      <th>Life expectancy</th>\n",
       "      <th>Adult Mortality</th>\n",
       "      <th>infant deaths</th>\n",
       "      <th>Alcohol</th>\n",
       "      <th>percentage expenditure</th>\n",
       "      <th>Hepatitis B</th>\n",
       "      <th>Measles</th>\n",
       "      <th>...</th>\n",
       "      <th>Polio</th>\n",
       "      <th>Total expenditure</th>\n",
       "      <th>Diphtheria</th>\n",
       "      <th>HIV/AIDS</th>\n",
       "      <th>GDP</th>\n",
       "      <th>Population</th>\n",
       "      <th>thinness  1-19 years</th>\n",
       "      <th>thinness 5-9 years</th>\n",
       "      <th>Income composition of resources</th>\n",
       "      <th>Schooling</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>2015</td>\n",
       "      <td>Developing</td>\n",
       "      <td>65.0</td>\n",
       "      <td>263.0</td>\n",
       "      <td>62</td>\n",
       "      <td>0.01</td>\n",
       "      <td>71.279624</td>\n",
       "      <td>65.0</td>\n",
       "      <td>1154</td>\n",
       "      <td>...</td>\n",
       "      <td>6.0</td>\n",
       "      <td>8.16</td>\n",
       "      <td>65.0</td>\n",
       "      <td>0.1</td>\n",
       "      <td>584.259210</td>\n",
       "      <td>33736494.0</td>\n",
       "      <td>17.2</td>\n",
       "      <td>17.3</td>\n",
       "      <td>0.479</td>\n",
       "      <td>10.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>2014</td>\n",
       "      <td>Developing</td>\n",
       "      <td>59.9</td>\n",
       "      <td>271.0</td>\n",
       "      <td>64</td>\n",
       "      <td>0.01</td>\n",
       "      <td>73.523582</td>\n",
       "      <td>62.0</td>\n",
       "      <td>492</td>\n",
       "      <td>...</td>\n",
       "      <td>58.0</td>\n",
       "      <td>8.18</td>\n",
       "      <td>62.0</td>\n",
       "      <td>0.1</td>\n",
       "      <td>612.696514</td>\n",
       "      <td>327582.0</td>\n",
       "      <td>17.5</td>\n",
       "      <td>17.5</td>\n",
       "      <td>0.476</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>2013</td>\n",
       "      <td>Developing</td>\n",
       "      <td>59.9</td>\n",
       "      <td>268.0</td>\n",
       "      <td>66</td>\n",
       "      <td>0.01</td>\n",
       "      <td>73.219243</td>\n",
       "      <td>64.0</td>\n",
       "      <td>430</td>\n",
       "      <td>...</td>\n",
       "      <td>62.0</td>\n",
       "      <td>8.13</td>\n",
       "      <td>64.0</td>\n",
       "      <td>0.1</td>\n",
       "      <td>631.744976</td>\n",
       "      <td>31731688.0</td>\n",
       "      <td>17.7</td>\n",
       "      <td>17.7</td>\n",
       "      <td>0.470</td>\n",
       "      <td>9.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>2012</td>\n",
       "      <td>Developing</td>\n",
       "      <td>59.5</td>\n",
       "      <td>272.0</td>\n",
       "      <td>69</td>\n",
       "      <td>0.01</td>\n",
       "      <td>78.184215</td>\n",
       "      <td>67.0</td>\n",
       "      <td>2787</td>\n",
       "      <td>...</td>\n",
       "      <td>67.0</td>\n",
       "      <td>8.52</td>\n",
       "      <td>67.0</td>\n",
       "      <td>0.1</td>\n",
       "      <td>669.959000</td>\n",
       "      <td>3696958.0</td>\n",
       "      <td>17.9</td>\n",
       "      <td>18.0</td>\n",
       "      <td>0.463</td>\n",
       "      <td>9.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>2011</td>\n",
       "      <td>Developing</td>\n",
       "      <td>59.2</td>\n",
       "      <td>275.0</td>\n",
       "      <td>71</td>\n",
       "      <td>0.01</td>\n",
       "      <td>7.097109</td>\n",
       "      <td>68.0</td>\n",
       "      <td>3013</td>\n",
       "      <td>...</td>\n",
       "      <td>68.0</td>\n",
       "      <td>7.87</td>\n",
       "      <td>68.0</td>\n",
       "      <td>0.1</td>\n",
       "      <td>63.537231</td>\n",
       "      <td>2978599.0</td>\n",
       "      <td>18.2</td>\n",
       "      <td>18.2</td>\n",
       "      <td>0.454</td>\n",
       "      <td>9.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 22 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       Country  Year      Status  Life expectancy   Adult Mortality  \\\n",
       "0  Afghanistan  2015  Developing              65.0            263.0   \n",
       "1  Afghanistan  2014  Developing              59.9            271.0   \n",
       "2  Afghanistan  2013  Developing              59.9            268.0   \n",
       "3  Afghanistan  2012  Developing              59.5            272.0   \n",
       "4  Afghanistan  2011  Developing              59.2            275.0   \n",
       "\n",
       "   infant deaths  Alcohol  percentage expenditure  Hepatitis B  Measles   \\\n",
       "0             62     0.01               71.279624         65.0      1154   \n",
       "1             64     0.01               73.523582         62.0       492   \n",
       "2             66     0.01               73.219243         64.0       430   \n",
       "3             69     0.01               78.184215         67.0      2787   \n",
       "4             71     0.01                7.097109         68.0      3013   \n",
       "\n",
       "     ...      Polio  Total expenditure  Diphtheria    HIV/AIDS         GDP  \\\n",
       "0    ...        6.0               8.16         65.0        0.1  584.259210   \n",
       "1    ...       58.0               8.18         62.0        0.1  612.696514   \n",
       "2    ...       62.0               8.13         64.0        0.1  631.744976   \n",
       "3    ...       67.0               8.52         67.0        0.1  669.959000   \n",
       "4    ...       68.0               7.87         68.0        0.1   63.537231   \n",
       "\n",
       "   Population   thinness  1-19 years   thinness 5-9 years  \\\n",
       "0  33736494.0                   17.2                 17.3   \n",
       "1    327582.0                   17.5                 17.5   \n",
       "2  31731688.0                   17.7                 17.7   \n",
       "3   3696958.0                   17.9                 18.0   \n",
       "4   2978599.0                   18.2                 18.2   \n",
       "\n",
       "   Income composition of resources  Schooling  \n",
       "0                            0.479       10.1  \n",
       "1                            0.476       10.0  \n",
       "2                            0.470        9.9  \n",
       "3                            0.463        9.8  \n",
       "4                            0.454        9.5  \n",
       "\n",
       "[5 rows x 22 columns]"
      ]
     },
     "execution_count": 695,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "led = pd.read_csv(\"Life Expectancy Data.csv\")\n",
    "led.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 696,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>workclass</th>\n",
       "      <th>fnlwgt</th>\n",
       "      <th>education</th>\n",
       "      <th>education.num</th>\n",
       "      <th>marital.status</th>\n",
       "      <th>occupation</th>\n",
       "      <th>relationship</th>\n",
       "      <th>race</th>\n",
       "      <th>sex</th>\n",
       "      <th>capital.gain</th>\n",
       "      <th>capital.loss</th>\n",
       "      <th>hours.per.week</th>\n",
       "      <th>native.country</th>\n",
       "      <th>income</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>90</td>\n",
       "      <td>?</td>\n",
       "      <td>77053</td>\n",
       "      <td>HS-grad</td>\n",
       "      <td>9</td>\n",
       "      <td>Widowed</td>\n",
       "      <td>?</td>\n",
       "      <td>Not-in-family</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>4356</td>\n",
       "      <td>40</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>82</td>\n",
       "      <td>Private</td>\n",
       "      <td>132870</td>\n",
       "      <td>HS-grad</td>\n",
       "      <td>9</td>\n",
       "      <td>Widowed</td>\n",
       "      <td>Exec-managerial</td>\n",
       "      <td>Not-in-family</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>4356</td>\n",
       "      <td>18</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>66</td>\n",
       "      <td>?</td>\n",
       "      <td>186061</td>\n",
       "      <td>Some-college</td>\n",
       "      <td>10</td>\n",
       "      <td>Widowed</td>\n",
       "      <td>?</td>\n",
       "      <td>Unmarried</td>\n",
       "      <td>Black</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>4356</td>\n",
       "      <td>40</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>54</td>\n",
       "      <td>Private</td>\n",
       "      <td>140359</td>\n",
       "      <td>7th-8th</td>\n",
       "      <td>4</td>\n",
       "      <td>Divorced</td>\n",
       "      <td>Machine-op-inspct</td>\n",
       "      <td>Unmarried</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>3900</td>\n",
       "      <td>40</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>41</td>\n",
       "      <td>Private</td>\n",
       "      <td>264663</td>\n",
       "      <td>Some-college</td>\n",
       "      <td>10</td>\n",
       "      <td>Separated</td>\n",
       "      <td>Prof-specialty</td>\n",
       "      <td>Own-child</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>3900</td>\n",
       "      <td>40</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>34</td>\n",
       "      <td>Private</td>\n",
       "      <td>216864</td>\n",
       "      <td>HS-grad</td>\n",
       "      <td>9</td>\n",
       "      <td>Divorced</td>\n",
       "      <td>Other-service</td>\n",
       "      <td>Unmarried</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>3770</td>\n",
       "      <td>45</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>38</td>\n",
       "      <td>Private</td>\n",
       "      <td>150601</td>\n",
       "      <td>10th</td>\n",
       "      <td>6</td>\n",
       "      <td>Separated</td>\n",
       "      <td>Adm-clerical</td>\n",
       "      <td>Unmarried</td>\n",
       "      <td>White</td>\n",
       "      <td>Male</td>\n",
       "      <td>0</td>\n",
       "      <td>3770</td>\n",
       "      <td>40</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>74</td>\n",
       "      <td>State-gov</td>\n",
       "      <td>88638</td>\n",
       "      <td>Doctorate</td>\n",
       "      <td>16</td>\n",
       "      <td>Never-married</td>\n",
       "      <td>Prof-specialty</td>\n",
       "      <td>Other-relative</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>3683</td>\n",
       "      <td>20</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&gt;50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>68</td>\n",
       "      <td>Federal-gov</td>\n",
       "      <td>422013</td>\n",
       "      <td>HS-grad</td>\n",
       "      <td>9</td>\n",
       "      <td>Divorced</td>\n",
       "      <td>Prof-specialty</td>\n",
       "      <td>Not-in-family</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>3683</td>\n",
       "      <td>40</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>41</td>\n",
       "      <td>Private</td>\n",
       "      <td>70037</td>\n",
       "      <td>Some-college</td>\n",
       "      <td>10</td>\n",
       "      <td>Never-married</td>\n",
       "      <td>Craft-repair</td>\n",
       "      <td>Unmarried</td>\n",
       "      <td>White</td>\n",
       "      <td>Male</td>\n",
       "      <td>0</td>\n",
       "      <td>3004</td>\n",
       "      <td>60</td>\n",
       "      <td>?</td>\n",
       "      <td>&gt;50K</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age    workclass  fnlwgt     education  education.num marital.status  \\\n",
       "0   90            ?   77053       HS-grad              9        Widowed   \n",
       "1   82      Private  132870       HS-grad              9        Widowed   \n",
       "2   66            ?  186061  Some-college             10        Widowed   \n",
       "3   54      Private  140359       7th-8th              4       Divorced   \n",
       "4   41      Private  264663  Some-college             10      Separated   \n",
       "5   34      Private  216864       HS-grad              9       Divorced   \n",
       "6   38      Private  150601          10th              6      Separated   \n",
       "7   74    State-gov   88638     Doctorate             16  Never-married   \n",
       "8   68  Federal-gov  422013       HS-grad              9       Divorced   \n",
       "9   41      Private   70037  Some-college             10  Never-married   \n",
       "\n",
       "          occupation    relationship   race     sex  capital.gain  \\\n",
       "0                  ?   Not-in-family  White  Female             0   \n",
       "1    Exec-managerial   Not-in-family  White  Female             0   \n",
       "2                  ?       Unmarried  Black  Female             0   \n",
       "3  Machine-op-inspct       Unmarried  White  Female             0   \n",
       "4     Prof-specialty       Own-child  White  Female             0   \n",
       "5      Other-service       Unmarried  White  Female             0   \n",
       "6       Adm-clerical       Unmarried  White    Male             0   \n",
       "7     Prof-specialty  Other-relative  White  Female             0   \n",
       "8     Prof-specialty   Not-in-family  White  Female             0   \n",
       "9       Craft-repair       Unmarried  White    Male             0   \n",
       "\n",
       "   capital.loss  hours.per.week native.country income  \n",
       "0          4356              40  United-States  <=50K  \n",
       "1          4356              18  United-States  <=50K  \n",
       "2          4356              40  United-States  <=50K  \n",
       "3          3900              40  United-States  <=50K  \n",
       "4          3900              40  United-States  <=50K  \n",
       "5          3770              45  United-States  <=50K  \n",
       "6          3770              40  United-States  <=50K  \n",
       "7          3683              20  United-States   >50K  \n",
       "8          3683              40  United-States  <=50K  \n",
       "9          3004              60              ?   >50K  "
      ]
     },
     "execution_count": 696,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "adult = pd.read_csv(\"adult.csv\")\n",
    "adult.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 697,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>workclass</th>\n",
       "      <th>fnlwgt</th>\n",
       "      <th>education</th>\n",
       "      <th>education.num</th>\n",
       "      <th>marital.status</th>\n",
       "      <th>occupation</th>\n",
       "      <th>relationship</th>\n",
       "      <th>race</th>\n",
       "      <th>sex</th>\n",
       "      <th>capital.gain</th>\n",
       "      <th>capital.loss</th>\n",
       "      <th>hours.per.week</th>\n",
       "      <th>native.country</th>\n",
       "      <th>income</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>82</td>\n",
       "      <td>Private</td>\n",
       "      <td>132870</td>\n",
       "      <td>HS-grad</td>\n",
       "      <td>9</td>\n",
       "      <td>Widowed</td>\n",
       "      <td>Exec-managerial</td>\n",
       "      <td>Not-in-family</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>4356</td>\n",
       "      <td>18</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>54</td>\n",
       "      <td>Private</td>\n",
       "      <td>140359</td>\n",
       "      <td>7th-8th</td>\n",
       "      <td>4</td>\n",
       "      <td>Divorced</td>\n",
       "      <td>Machine-op-inspct</td>\n",
       "      <td>Unmarried</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>3900</td>\n",
       "      <td>40</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>41</td>\n",
       "      <td>Private</td>\n",
       "      <td>264663</td>\n",
       "      <td>Some-college</td>\n",
       "      <td>10</td>\n",
       "      <td>Separated</td>\n",
       "      <td>Prof-specialty</td>\n",
       "      <td>Own-child</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>3900</td>\n",
       "      <td>40</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>34</td>\n",
       "      <td>Private</td>\n",
       "      <td>216864</td>\n",
       "      <td>HS-grad</td>\n",
       "      <td>9</td>\n",
       "      <td>Divorced</td>\n",
       "      <td>Other-service</td>\n",
       "      <td>Unmarried</td>\n",
       "      <td>White</td>\n",
       "      <td>Female</td>\n",
       "      <td>0</td>\n",
       "      <td>3770</td>\n",
       "      <td>45</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>38</td>\n",
       "      <td>Private</td>\n",
       "      <td>150601</td>\n",
       "      <td>10th</td>\n",
       "      <td>6</td>\n",
       "      <td>Separated</td>\n",
       "      <td>Adm-clerical</td>\n",
       "      <td>Unmarried</td>\n",
       "      <td>White</td>\n",
       "      <td>Male</td>\n",
       "      <td>0</td>\n",
       "      <td>3770</td>\n",
       "      <td>40</td>\n",
       "      <td>United-States</td>\n",
       "      <td>&lt;=50K</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age workclass  fnlwgt     education  education.num marital.status  \\\n",
       "1   82   Private  132870       HS-grad              9        Widowed   \n",
       "3   54   Private  140359       7th-8th              4       Divorced   \n",
       "4   41   Private  264663  Some-college             10      Separated   \n",
       "5   34   Private  216864       HS-grad              9       Divorced   \n",
       "6   38   Private  150601          10th              6      Separated   \n",
       "\n",
       "          occupation   relationship   race     sex  capital.gain  \\\n",
       "1    Exec-managerial  Not-in-family  White  Female             0   \n",
       "3  Machine-op-inspct      Unmarried  White  Female             0   \n",
       "4     Prof-specialty      Own-child  White  Female             0   \n",
       "5      Other-service      Unmarried  White  Female             0   \n",
       "6       Adm-clerical      Unmarried  White    Male             0   \n",
       "\n",
       "   capital.loss  hours.per.week native.country income  \n",
       "1          4356              18  United-States  <=50K  \n",
       "3          3900              40  United-States  <=50K  \n",
       "4          3900              40  United-States  <=50K  \n",
       "5          3770              45  United-States  <=50K  \n",
       "6          3770              40  United-States  <=50K  "
      ]
     },
     "execution_count": 697,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "adult = adult[adult[\"workclass\"].isin (['Private', 'State-gov', 'Federal-gov'])]\n",
    "adult.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 698,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sepal_length</th>\n",
       "      <th>sepal_width</th>\n",
       "      <th>petal_length</th>\n",
       "      <th>petal_width</th>\n",
       "      <th>species</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>setosa</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>setosa</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.2</td>\n",
       "      <td>setosa</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>setosa</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>setosa</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   sepal_length  sepal_width  petal_length  petal_width species\n",
       "0           5.1          3.5           1.4          0.2  setosa\n",
       "1           4.9          3.0           1.4          0.2  setosa\n",
       "2           4.7          3.2           1.3          0.2  setosa\n",
       "3           4.6          3.1           1.5          0.2  setosa\n",
       "4           5.0          3.6           1.4          0.2  setosa"
      ]
     },
     "execution_count": 698,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "iris = sns.load_dataset(\"iris\")\n",
    "iris.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 700,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>mpg</th>\n",
       "      <th>cylinders</th>\n",
       "      <th>cubicinches</th>\n",
       "      <th>hp</th>\n",
       "      <th>weightlbs</th>\n",
       "      <th>time-to-60</th>\n",
       "      <th>year</th>\n",
       "      <th>brand</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>14.0</td>\n",
       "      <td>8</td>\n",
       "      <td>350</td>\n",
       "      <td>165</td>\n",
       "      <td>4209</td>\n",
       "      <td>12</td>\n",
       "      <td>1972</td>\n",
       "      <td>US.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>31.9</td>\n",
       "      <td>4</td>\n",
       "      <td>89</td>\n",
       "      <td>71</td>\n",
       "      <td>1925</td>\n",
       "      <td>14</td>\n",
       "      <td>1980</td>\n",
       "      <td>Europe.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>17.0</td>\n",
       "      <td>8</td>\n",
       "      <td>302</td>\n",
       "      <td>140</td>\n",
       "      <td>3449</td>\n",
       "      <td>11</td>\n",
       "      <td>1971</td>\n",
       "      <td>US.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>15.0</td>\n",
       "      <td>8</td>\n",
       "      <td>400</td>\n",
       "      <td>150</td>\n",
       "      <td>3761</td>\n",
       "      <td>10</td>\n",
       "      <td>1971</td>\n",
       "      <td>US.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>30.5</td>\n",
       "      <td>4</td>\n",
       "      <td>98</td>\n",
       "      <td>63</td>\n",
       "      <td>2051</td>\n",
       "      <td>17</td>\n",
       "      <td>1978</td>\n",
       "      <td>US.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>23.0</td>\n",
       "      <td>8</td>\n",
       "      <td>350</td>\n",
       "      <td>125</td>\n",
       "      <td>3900</td>\n",
       "      <td>17</td>\n",
       "      <td>1980</td>\n",
       "      <td>US.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>13.0</td>\n",
       "      <td>8</td>\n",
       "      <td>351</td>\n",
       "      <td>158</td>\n",
       "      <td>4363</td>\n",
       "      <td>13</td>\n",
       "      <td>1974</td>\n",
       "      <td>US.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>14.0</td>\n",
       "      <td>8</td>\n",
       "      <td>440</td>\n",
       "      <td>215</td>\n",
       "      <td>4312</td>\n",
       "      <td>9</td>\n",
       "      <td>1971</td>\n",
       "      <td>US.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>25.4</td>\n",
       "      <td>5</td>\n",
       "      <td>183</td>\n",
       "      <td>77</td>\n",
       "      <td>3530</td>\n",
       "      <td>20</td>\n",
       "      <td>1980</td>\n",
       "      <td>Europe.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>37.7</td>\n",
       "      <td>4</td>\n",
       "      <td>89</td>\n",
       "      <td>62</td>\n",
       "      <td>2050</td>\n",
       "      <td>17</td>\n",
       "      <td>1982</td>\n",
       "      <td>Japan.</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    mpg   cylinders  cubicinches   hp  weightlbs   time-to-60   year     brand\n",
       "0  14.0           8          350  165       4209           12   1972       US.\n",
       "1  31.9           4           89   71       1925           14   1980   Europe.\n",
       "2  17.0           8          302  140       3449           11   1971       US.\n",
       "3  15.0           8          400  150       3761           10   1971       US.\n",
       "4  30.5           4           98   63       2051           17   1978       US.\n",
       "5  23.0           8          350  125       3900           17   1980       US.\n",
       "6  13.0           8          351  158       4363           13   1974       US.\n",
       "7  14.0           8          440  215       4312            9   1971       US.\n",
       "8  25.4           5          183   77       3530           20   1980   Europe.\n",
       "9  37.7           4           89   62       2050           17   1982    Japan."
      ]
     },
     "execution_count": 700,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cars = pd.read_csv(\"cars.csv\")\n",
    "cars.head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Line Charts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>C1</th>\n",
       "      <th>C2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.01001</td>\n",
       "      <td>0.010010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.02002</td>\n",
       "      <td>0.020019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.03003</td>\n",
       "      <td>0.030026</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.04004</td>\n",
       "      <td>0.040029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.05005</td>\n",
       "      <td>0.050029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.06006</td>\n",
       "      <td>0.060024</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.07007</td>\n",
       "      <td>0.070013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.08008</td>\n",
       "      <td>0.079995</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.09009</td>\n",
       "      <td>0.089968</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        C1        C2\n",
       "0  0.00000  0.000000\n",
       "1  0.01001  0.010010\n",
       "2  0.02002  0.020019\n",
       "3  0.03003  0.030026\n",
       "4  0.04004  0.040029\n",
       "5  0.05005  0.050029\n",
       "6  0.06006  0.060024\n",
       "7  0.07007  0.070013\n",
       "8  0.08008  0.079995\n",
       "9  0.09009  0.089968"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "col1 = np.linspace(0, 10, 1000)\n",
    "col2 = np.sin(col1)\n",
    "df = pd.DataFrame({\"C1\" : col1 , \"C2\" :col2})\n",
    "df.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 19692 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plotting lineplot using sns.lineplot()\n",
    "plt.style.use('seaborn-darkgrid')\n",
    "%matplotlib inline \n",
    "sns.lineplot(x=df.C1,y=df.C2,data=df)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 50032 characters]\n",
      "text/plain": [
       "<Figure size 1008x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\"  - Adjusting background color using axes.facecolor\n",
    "     - Changing label size using xtick.labelsize , ytick.labelsize \"\"\"\n",
    "\n",
    "plt.figure(figsize=(14,6))\n",
    "sns.set(rc={\"axes.facecolor\":\"#FFFDE7\", \"axes.grid\":True,'xtick.labelsize':14,'ytick.labelsize':14})\n",
    "sns.lineplot(x=df.C1,y=df.C2,data=df , linewidth = 2)\n",
    "sns.lineplot(x=df.C1,y=df.C2+1,data=df , linewidth = 2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 58136 characters]\n",
      "text/plain": [
       "<Figure size 1008x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\"  - Adjusting background color using axes.facecolor\n",
    "     - Changing label size using xtick.labelsize , ytick.labelsize \"\"\"\n",
    "\n",
    "plt.figure(figsize=(14,6))\n",
    "sns.set(rc={\"axes.facecolor\":\"#283747\", \"axes.grid\":False,'xtick.labelsize':14,'ytick.labelsize':14})\n",
    "sns.lineplot(x=df.C1,y=df.C2,data=df , color = \"#FF5722\" , linewidth = 2 )\n",
    "sns.lineplot(x=df.C1,y=np.cos(df.C1),data=df , color = \"#FFEB3B\" , linewidth = 2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 163128 characters]\n",
      "text/plain": [
       "<Figure size 1440x576 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,8))\n",
    "sns.lineplot(data=spotify)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Look at the X-Asis. It is clealy not able to interpret the Index as Date. So the next step will be to convert the Index to Datetime."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "spotify.index = pd.to_datetime(spotify.index) # Converting datatype of index to Datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 166084 characters]\n",
      "text/plain": [
       "<Figure size 1440x576 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,8))\n",
    "sns.lineplot(data=spotify,linewidth = 2)\n",
    "plt.title(\"Daily Global Streams\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 156000 characters]\n",
      "text/plain": [
       "<Figure size 1440x576 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Using Matplotlib for same visualization\n",
    "import matplotlib as mpl\n",
    "plt.figure(figsize=(20,8))\n",
    "plt.plot(spotify['Despacito'] , label=\"Despacito\")\n",
    "plt.plot(spotify['Shape of You'] , label=\"Shape of You\")\n",
    "plt.plot(spotify['Something Just Like This'] , label=\"Something Just Like This\")\n",
    "plt.plot(spotify['HUMBLE.'] , label=\"Humble\")\n",
    "plt.plot(spotify['Unforgettable'] , label=\"Unforgettable\")\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So we can see using Seabon we can save many lines of code."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 67176 characters]\n",
      "text/plain": [
       "<Figure size 1440x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,6))\n",
    "sns.lineplot(data=spotify['Despacito'],linewidth = 1.5 , label = 'Despacito')\n",
    "sns.lineplot(data=spotify['HUMBLE.'],linewidth = 1.5 , label = 'Humble')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Afghanistan</th>\n",
       "      <th>Albania</th>\n",
       "      <th>Algeria</th>\n",
       "      <th>American Samoa</th>\n",
       "      <th>Andorra</th>\n",
       "      <th>Angola</th>\n",
       "      <th>Antigua and Barbuda</th>\n",
       "      <th>Argentina</th>\n",
       "      <th>Armenia</th>\n",
       "      <th>Australia</th>\n",
       "      <th>...</th>\n",
       "      <th>Uzbekistan</th>\n",
       "      <th>Vanuatu</th>\n",
       "      <th>Venezuela (Bolivarian Republic of)</th>\n",
       "      <th>Viet Nam</th>\n",
       "      <th>Western Sahara</th>\n",
       "      <th>Yemen</th>\n",
       "      <th>Zambia</th>\n",
       "      <th>Zimbabwe</th>\n",
       "      <th>Unknown</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1980</th>\n",
       "      <td>16</td>\n",
       "      <td>1</td>\n",
       "      <td>80</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>368</td>\n",
       "      <td>0</td>\n",
       "      <td>702</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>103</td>\n",
       "      <td>1191</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>11</td>\n",
       "      <td>72</td>\n",
       "      <td>44000</td>\n",
       "      <td>143137</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1981</th>\n",
       "      <td>39</td>\n",
       "      <td>0</td>\n",
       "      <td>67</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>426</td>\n",
       "      <td>0</td>\n",
       "      <td>639</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>117</td>\n",
       "      <td>1829</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>17</td>\n",
       "      <td>114</td>\n",
       "      <td>18078</td>\n",
       "      <td>128641</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1982</th>\n",
       "      <td>39</td>\n",
       "      <td>0</td>\n",
       "      <td>71</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>626</td>\n",
       "      <td>0</td>\n",
       "      <td>484</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>174</td>\n",
       "      <td>2162</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>11</td>\n",
       "      <td>102</td>\n",
       "      <td>16904</td>\n",
       "      <td>121175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1983</th>\n",
       "      <td>47</td>\n",
       "      <td>0</td>\n",
       "      <td>69</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>241</td>\n",
       "      <td>0</td>\n",
       "      <td>317</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>124</td>\n",
       "      <td>3404</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>44</td>\n",
       "      <td>13635</td>\n",
       "      <td>89185</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1984</th>\n",
       "      <td>71</td>\n",
       "      <td>0</td>\n",
       "      <td>63</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>42</td>\n",
       "      <td>237</td>\n",
       "      <td>0</td>\n",
       "      <td>317</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>142</td>\n",
       "      <td>7583</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>32</td>\n",
       "      <td>14855</td>\n",
       "      <td>88272</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 197 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Afghanistan  Albania  Algeria  American Samoa  Andorra  Angola  \\\n",
       "1980           16        1       80               0        0       1   \n",
       "1981           39        0       67               1        0       3   \n",
       "1982           39        0       71               0        0       6   \n",
       "1983           47        0       69               0        0       6   \n",
       "1984           71        0       63               0        0       4   \n",
       "\n",
       "      Antigua and Barbuda  Argentina  Armenia  Australia   ...    Uzbekistan  \\\n",
       "1980                    0        368        0        702   ...             0   \n",
       "1981                    0        426        0        639   ...             0   \n",
       "1982                    0        626        0        484   ...             0   \n",
       "1983                    0        241        0        317   ...             0   \n",
       "1984                   42        237        0        317   ...             0   \n",
       "\n",
       "      Vanuatu  Venezuela (Bolivarian Republic of)  Viet Nam  Western Sahara  \\\n",
       "1980        0                                 103      1191               0   \n",
       "1981        0                                 117      1829               0   \n",
       "1982        0                                 174      2162               0   \n",
       "1983        0                                 124      3404               0   \n",
       "1984        0                                 142      7583               0   \n",
       "\n",
       "      Yemen  Zambia  Zimbabwe  Unknown   Total  \n",
       "1980      1      11        72    44000  143137  \n",
       "1981      2      17       114    18078  128641  \n",
       "1982      1      11       102    16904  121175  \n",
       "1983      6       7        44    13635   89185  \n",
       "1984      0      16        32    14855   88272  \n",
       "\n",
       "[5 rows x 197 columns]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "canada.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 701,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 48108 characters]\n",
      "text/plain": [
       "<Figure size 1152x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(16,6))\n",
    "plt.title(\"Immigrants from India\",fontsize = 14)\n",
    "sns.set(rc={\"axes.facecolor\":\"#283747\", \"axes.grid\":False,'xtick.labelsize':10,'ytick.labelsize':10})\n",
    "plt.xticks(rotation=45) # Rotating X tickts by 45 degrees\n",
    "sns.lineplot(x = canada.index.values, y = canada['India'])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 702,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 73624 characters]\n",
      "text/plain": [
       "<Figure size 1152x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plotting multiple sets of data (E.g Immigration data of multiple countries in one plot)\n",
    "plt.figure(figsize=(16,6))\n",
    "sns.set(rc={\"axes.facecolor\":\"#283747\", \"axes.grid\":False,'xtick.labelsize':10,'ytick.labelsize':10})\n",
    "plt.title(\"Immigrants from India , Pakistan & Bangladesh\",fontsize = 14)\n",
    "plt.xticks(rotation=45) # Rotating X tickts by 45 degrees\n",
    "sns.lineplot(x = canada.index.values, y = canada['India'] , color = '#ff9900' , label= 'India')\n",
    "sns.lineplot(x = canada.index.values, y = canada['Pakistan'] , color = '#4586ff' , label = 'Pakistan')\n",
    "sns.lineplot(x = canada.index.values, y = canada['Bangladesh'] , color = '#a2ef44' , label = 'Bangladesh')\n",
    "plt.legend(facecolor= 'grey' , fontsize='large' , edgecolor = 'black' ,shadow=True) # Legend formatting\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 179236 characters]\n",
      "text/plain": [
       "<Figure size 1152x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plotting multiple sets of data using for loop (E.g Immigration data of multiple countries in one plot)\n",
    "plt.figure(figsize=(16,6))\n",
    "plt.title(\"Immigrants\",fontsize = 16)\n",
    "for i in canada.columns:\n",
    "    if canada[i].name != 'Total' and canada[i].name != 'Unknown':\n",
    "        x=canada.index.values\n",
    "        y=canada[i]\n",
    "        sns.lineplot(x,y)\n",
    "plt.xlabel ('Year')\n",
    "plt.ylabel ('Country')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Period</th>\n",
       "      <th>Unemployed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>16 to 19 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>91000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20 to 24 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>175000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>25 to 34 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>194000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>35 to 44 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>201000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>207000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Age Gender     Period  Unemployed\n",
       "0  16 to 19 years    Men 2005-01-01       91000\n",
       "1  20 to 24 years    Men 2005-01-01      175000\n",
       "2  25 to 34 years    Men 2005-01-01      194000\n",
       "3  35 to 44 years    Men 2005-01-01      201000\n",
       "4  45 to 54 years    Men 2005-01-01      207000"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employment.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 93604 characters]\n",
      "text/plain": [
       "<Figure size 1008x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\"\n",
    "plt.figure(figsize=(14,7))\n",
    "plt.style.use('seaborn-darkgrid')\n",
    "# Group variable using \"hue\" that will produce lines with different colors\n",
    "sns.lineplot(x=\"Period\" , y=\"Unemployed\" , hue=\"Gender\" , data=employment) \n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 101468 characters]\n",
      "text/plain": [
       "<Figure size 1008x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Using markers to identify groups\n",
    "plt.figure(figsize=(14,7))\n",
    "plt.style.use('seaborn-darkgrid')\n",
    "sns.lineplot(x=\"Period\" , y=\"Unemployed\" , hue = \"Gender\" ,style=\"Gender\" , markers=True , dashes=False ,data=employment)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 57128 characters]\n",
      "text/plain": [
       "<Figure size 1008x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(14,7))\n",
    "plt.style.use('seaborn-darkgrid')\n",
    "sns.lineplot(x=\"Period\" , y=\"Unemployed\" , hue = \"Gender\" ,style=\"Gender\" ,  err_style=\"bars\", ci=70, data=employment)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 99512 characters]\n",
      "text/plain": [
       "<Figure size 1008x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(14,7))\n",
    "sns.set(rc={'xtick.labelsize':17,'ytick.labelsize':10,'axes.labelsize':15 , \"axes.grid\":False})\n",
    "\n",
    "# Use \"Pallete\" to specify the colors to be used for different levels of the hue\n",
    "sns.lineplot(x=\"Period\" , y=\"Unemployed\", data = employment, hue = \"Gender\",\n",
    "            style = \"Gender\", dashes = False, palette = 'CMRmap' , markers = [\"o\", \">\"])\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 708,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 300532 characters]\n",
      "text/plain": [
       "<Figure size 1152x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Color and line dashing to represent 2 different grouping variables using \"hue\" & \"style\"\n",
    "plt.figure(figsize=(16,9))\n",
    "plt.style.use('seaborn-darkgrid')\n",
    "plt.gcf().text(.2, .84, \"Line Plot\", fontsize = 40, color='Black' ,ha='center', va='center')\n",
    "sns.lineplot(x=\"Period\" , y=\"Unemployed\" , hue=\"Age\" , style=\"Gender\" , data=employment)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Period</th>\n",
       "      <th>Unemployed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>177</th>\n",
       "      <td>25 to 34 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2006-01-01</td>\n",
       "      <td>92000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>178</th>\n",
       "      <td>35 to 44 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2006-01-01</td>\n",
       "      <td>134000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>179</th>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2006-01-01</td>\n",
       "      <td>110000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>180</th>\n",
       "      <td>55 to 64 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2006-01-01</td>\n",
       "      <td>85000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>181</th>\n",
       "      <td>65 years and over</td>\n",
       "      <td>Women</td>\n",
       "      <td>2006-01-01</td>\n",
       "      <td>61000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Age Gender     Period  Unemployed\n",
       "177     25 to 34 years  Women 2006-01-01       92000\n",
       "178     35 to 44 years  Women 2006-01-01      134000\n",
       "179     45 to 54 years  Women 2006-01-01      110000\n",
       "180     55 to 64 years  Women 2006-01-01       85000\n",
       "181  65 years and over  Women 2006-01-01       61000"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "emp = employment[employment.Period.between('2005-01-01', '2006-01-01' , inclusive = True)]\n",
    "emp.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 185884 characters]\n",
      "text/plain": [
       "<Figure size 1008x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Showing all experiments instead of Aggregate using \"units\" and \"estimator\"\n",
    "plt.figure(figsize=(14,7))\n",
    "plt.style.use('seaborn-darkgrid')\n",
    "sns.lineplot(x=\"Period\" , y=\"Unemployed\" , hue = \"Age\" ,style=\"Gender\" ,\n",
    " units=\"Age\" ,markers=True , dashes=False ,estimator=None, lw=1,data=emp)\n",
    "plt.legend(bbox_to_anchor=(1.0, 1.0) , shadow=True, fontsize='large')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 720x720 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 283044 characters]\n",
      "text/plain": [
       "<Figure size 1351.47x612 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Combining lineplots using relplot\n",
    "plt.figure(figsize=(10,10))\n",
    "sns.set(rc={'xtick.labelsize':17,'ytick.labelsize':17,'axes.labelsize':20  , \"axes.grid\":False})\n",
    "sns.relplot(x=\"Period\" , y=\"Unemployed\" , hue=\"Age\" , col=\"Gender\",kind='line', height=8.5, aspect=1 ,data=employment)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>Confirmed</th>\n",
       "      <th>Recovered</th>\n",
       "      <th>Deaths</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Albania</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Algeria</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Andorra</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-01-22</th>\n",
       "      <td>Angola</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                Country  Confirmed  Recovered  Deaths\n",
       "Date                                                 \n",
       "2020-01-22  Afghanistan          0          0       0\n",
       "2020-01-22      Albania          0          0       0\n",
       "2020-01-22      Algeria          0          0       0\n",
       "2020-01-22      Andorra          0          0       0\n",
       "2020-01-22       Angola          0          0       0"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "corona.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 43736 characters]\n",
      "text/plain": [
       "<Figure size 1440x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,6))\n",
    "sns.lineplot(data=corona[corona['Country'] == 'Italy']['Confirmed'] , label = \"Confirmed\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'Italy']['Deaths'] , label = \"Deaths\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'Italy']['Recovered'], label = \"Recovered\")\n",
    "plt.title(\"Total Confirmed Cases / Deaths / Recovered in Italy\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 38568 characters]\n",
      "text/plain": [
       "<Figure size 1440x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,6))\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Confirmed'] , label = \"Confirmed\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Deaths'] , label = \"Deaths\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Recovered'], label = \"Recovered\")\n",
    "plt.title(\"Total Confirmed Cases / Deaths / Recovered in USA\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Plot Styling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 39672 characters]\n",
      "text/plain": [
       "<Figure size 1440x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Enabling whitegrid style\n",
    "sns.set_style(\"whitegrid\")\n",
    "plt.figure(figsize=(20,6))\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Confirmed'] , label = \"Confirmed\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Deaths'] , label = \"Deaths\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Recovered'], label = \"Recovered\")\n",
    "plt.title(\"Total Confirmed Cases / Deaths / Recovered in USA\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There will be horizontal grid lines in the background for \"whitegrid\" style."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 39600 characters]\n",
      "text/plain": [
       "<Figure size 1440x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Enabling darkgrid style\n",
    "sns.set_style(\"darkgrid\") \n",
    "plt.figure(figsize=(20,6))\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Confirmed'] , label = \"Confirmed\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Deaths'] , label = \"Deaths\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Recovered'], label = \"Recovered\")\n",
    "plt.title(\"Total Confirmed Cases / Deaths / Recovered in USA\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There will be horizontal grid lines in the background for \"darkgrid\" style. Also we will see a dark Background."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 39276 characters]\n",
      "text/plain": [
       "<Figure size 1440x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Ticks Style\n",
    "sns.set_style(\"ticks\")\n",
    "plt.figure(figsize=(20,6))\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Confirmed'] , label = \"Confirmed\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Deaths'] , label = \"Deaths\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Recovered'], label = \"Recovered\")\n",
    "plt.title(\"Total Confirmed Cases / Deaths / Recovered in USA\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There will be no horizontal grid lines in the background for \"ticks\" style. We will only see ticks in $X$ & $Y$ axis"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### $   Revert  $ $  to $  $ default $  $  styling  $"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 38604 characters]\n",
      "text/plain": [
       "<Figure size 1440x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.set_style(\"white\")\n",
    "plt.figure(figsize=(20,6))\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Confirmed'] , label = \"Confirmed\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Deaths'] , label = \"Deaths\")\n",
    "sns.lineplot(data=corona[corona['Country'] == 'US']['Recovered'], label = \"Recovered\")\n",
    "plt.title(\"Total Confirmed Cases / Deaths / Recovered in USA\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# SCatter Plots"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 709,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 956,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>sex</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>smoker</th>\n",
       "      <th>region</th>\n",
       "      <th>charges</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "      <td>southwest</td>\n",
       "      <td>16884.92400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>1725.55230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>male</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>4449.46200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>male</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>21984.47061</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>male</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>3866.85520</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     sex     bmi  children smoker     region      charges\n",
       "0   19  female  27.900         0    yes  southwest  16884.92400\n",
       "1   18    male  33.770         1     no  southeast   1725.55230\n",
       "2   28    male  33.000         3     no  southeast   4449.46200\n",
       "3   33    male  22.705         0     no  northwest  21984.47061\n",
       "4   32    male  28.880         0     no  northwest   3866.85520"
      ]
     },
     "execution_count": 956,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insurance.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 957,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 62088 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(7,7))\n",
    "sns.scatterplot(x=insurance.bmi , y=insurance.charges )\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 958,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 60712 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Changing the color of data points using \"color\" parameter\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.scatterplot(x=insurance.bmi , y=insurance.charges , color='#91bd3a')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 959,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 67764 characters]\n",
      "text/plain": [
       "<Figure size 576x576 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Changing the shape of data points using \"marker\" parameter\n",
    "plt.figure(figsize=(8,8))\n",
    "sns.scatterplot(x=insurance.bmi , y=insurance.charges , color='#339900' , marker = \">\"  )\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 960,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 118840 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\"\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.scatterplot(x=insurance.bmi , y=insurance.charges , hue=insurance.sex )\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 961,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 105340 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\"\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.scatterplot(x=insurance.bmi , y=insurance.charges , hue=insurance.smoker)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 962,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 92896 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Setting X limit using \"plt.xlim\"\n",
    "plt.figure(figsize=(7,7))\n",
    "plt.xlim([0,55])\n",
    "sns.scatterplot(x=insurance.bmi , y=insurance.charges , hue=insurance.smoker)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 970,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 153432 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Showing two different grouping variables using \"hue\" amd \"style\" parameter\n",
    "plt.figure(figsize=(10,10))\n",
    "plt.gcf().text(.5, .9, \"Scatter Plot\", fontsize = 40, color='Black' ,ha='center', va='center')\n",
    "sns.scatterplot(x=insurance.bmi , y=insurance.charges , hue=insurance.smoker,style=insurance.sex)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 220,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gender</th>\n",
       "      <th>race/ethnicity</th>\n",
       "      <th>parental level of education</th>\n",
       "      <th>lunch</th>\n",
       "      <th>test preparation course</th>\n",
       "      <th>math score</th>\n",
       "      <th>reading score</th>\n",
       "      <th>writing score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>bachelor's degree</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>72</td>\n",
       "      <td>72</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>female</td>\n",
       "      <td>group C</td>\n",
       "      <td>some college</td>\n",
       "      <td>standard</td>\n",
       "      <td>completed</td>\n",
       "      <td>69</td>\n",
       "      <td>90</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>master's degree</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>90</td>\n",
       "      <td>95</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>male</td>\n",
       "      <td>group A</td>\n",
       "      <td>associate's degree</td>\n",
       "      <td>free/reduced</td>\n",
       "      <td>none</td>\n",
       "      <td>47</td>\n",
       "      <td>57</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>male</td>\n",
       "      <td>group C</td>\n",
       "      <td>some college</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>76</td>\n",
       "      <td>78</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   gender race/ethnicity parental level of education         lunch  \\\n",
       "0  female        group B           bachelor's degree      standard   \n",
       "1  female        group C                some college      standard   \n",
       "2  female        group B             master's degree      standard   \n",
       "3    male        group A          associate's degree  free/reduced   \n",
       "4    male        group C                some college      standard   \n",
       "\n",
       "  test preparation course  math score  reading score  writing score  \n",
       "0                    none          72             72             74  \n",
       "1               completed          69             90             88  \n",
       "2                    none          90             95             93  \n",
       "3                    none          47             57             44  \n",
       "4                    none          76             78             75  "
      ]
     },
     "execution_count": 220,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stdperf.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 221,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 106412 characters]\n",
      "text/plain": [
       "<Figure size 648x648 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(9,9))\n",
    "sns.scatterplot(x= stdperf['reading score'] , y= stdperf['writing score'] ,\n",
    "                hue=stdperf['test preparation course'],size = stdperf['math score'] , sizes = (10,200))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 222,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>#</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type 1</th>\n",
       "      <th>Type 2</th>\n",
       "      <th>HP</th>\n",
       "      <th>Attack</th>\n",
       "      <th>Defense</th>\n",
       "      <th>Sp. Atk</th>\n",
       "      <th>Sp. Def</th>\n",
       "      <th>Speed</th>\n",
       "      <th>Generation</th>\n",
       "      <th>Legendary</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Bulbasaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>45</td>\n",
       "      <td>49</td>\n",
       "      <td>49</td>\n",
       "      <td>65</td>\n",
       "      <td>65</td>\n",
       "      <td>45</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>318</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Ivysaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>60</td>\n",
       "      <td>62</td>\n",
       "      <td>63</td>\n",
       "      <td>80</td>\n",
       "      <td>80</td>\n",
       "      <td>60</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Venusaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>80</td>\n",
       "      <td>82</td>\n",
       "      <td>83</td>\n",
       "      <td>100</td>\n",
       "      <td>100</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>525</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>VenusaurMega Venusaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>80</td>\n",
       "      <td>100</td>\n",
       "      <td>123</td>\n",
       "      <td>122</td>\n",
       "      <td>120</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>Charmander</td>\n",
       "      <td>Fire</td>\n",
       "      <td>NaN</td>\n",
       "      <td>39</td>\n",
       "      <td>52</td>\n",
       "      <td>43</td>\n",
       "      <td>60</td>\n",
       "      <td>50</td>\n",
       "      <td>65</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>309</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   #                   Name Type 1  Type 2  HP  Attack  Defense  Sp. Atk  \\\n",
       "0  1              Bulbasaur  Grass  Poison  45      49       49       65   \n",
       "1  2                Ivysaur  Grass  Poison  60      62       63       80   \n",
       "2  3               Venusaur  Grass  Poison  80      82       83      100   \n",
       "3  3  VenusaurMega Venusaur  Grass  Poison  80     100      123      122   \n",
       "4  4             Charmander   Fire     NaN  39      52       43       60   \n",
       "\n",
       "   Sp. Def  Speed  Generation  Legendary  Total  \n",
       "0       65     45           1      False    318  \n",
       "1       80     60           1      False    405  \n",
       "2      100     80           1      False    525  \n",
       "3      120     80           1      False    625  \n",
       "4       50     65           1      False    309  "
      ]
     },
     "execution_count": 222,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pokemon.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 223,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 144796 characters]\n",
      "text/plain": [
       "<Figure size 648x648 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Varying the size of the points for a quantitative variable using \"size\" parameter\n",
    "plt.figure(figsize=(9,9))\n",
    "sns.scatterplot(x= pokemon['Speed'] , y= pokemon['Attack'] ,hue= pokemon['Legendary'] , \n",
    "                size = pokemon['Sp. Atk'] , sizes = (20,200))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Relplot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Relplot provides access to several different axes-level functions like line & scatter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 224,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.set_style(\"white\") "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 225,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Period</th>\n",
       "      <th>Unemployed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>16 to 19 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>91000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20 to 24 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>175000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>25 to 34 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>194000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>35 to 44 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>201000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>207000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Age Gender     Period  Unemployed\n",
       "0  16 to 19 years    Men 2005-01-01       91000\n",
       "1  20 to 24 years    Men 2005-01-01      175000\n",
       "2  25 to 34 years    Men 2005-01-01      194000\n",
       "3  35 to 44 years    Men 2005-01-01      201000\n",
       "4  45 to 54 years    Men 2005-01-01      207000"
      ]
     },
     "execution_count": 225,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employment.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 226,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 1008x1152 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 194160 characters]\n",
      "text/plain": [
       "<Figure size 1078.62x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Drawing scatter plot using relplot\n",
    "plt.figure(figsize=(14,16))\n",
    "sns.relplot(x=\"Period\" , y=\"Unemployed\" , hue=\"Gender\" ,data=employment , height=7 , aspect=2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 227,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 1008x1152 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 132712 characters]\n",
      "text/plain": [
       "<Figure size 645x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Drawing scatter plot using relplot\n",
    "plt.figure(figsize=(14,16))\n",
    "sns.relplot(x=\"bmi\" , y=\"charges\" , hue=\"smoker\" ,data=insurance , height=8 , aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 228,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 169228 characters]\n",
      "text/plain": [
       "<Figure size 651.725x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Use \"Pallete\" to specify the colors to be used for different levels of the hue\n",
    "sns.set(rc={'xtick.labelsize':12,'ytick.labelsize':12,'axes.labelsize':12  , \"axes.grid\":False})\n",
    "sns.relplot(x=\"bmi\" , y=\"charges\" , hue=\"smoker\" ,data=insurance , height=8 , aspect=1 , \n",
    "            palette=[\"#FF3333\" ,\"#00CC00\"])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 229,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Species</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Length1</th>\n",
       "      <th>Length2</th>\n",
       "      <th>Length3</th>\n",
       "      <th>Height</th>\n",
       "      <th>Width</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Bream</td>\n",
       "      <td>242.0</td>\n",
       "      <td>23.2</td>\n",
       "      <td>25.4</td>\n",
       "      <td>30.0</td>\n",
       "      <td>11.5200</td>\n",
       "      <td>4.0200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Bream</td>\n",
       "      <td>290.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>26.3</td>\n",
       "      <td>31.2</td>\n",
       "      <td>12.4800</td>\n",
       "      <td>4.3056</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Bream</td>\n",
       "      <td>340.0</td>\n",
       "      <td>23.9</td>\n",
       "      <td>26.5</td>\n",
       "      <td>31.1</td>\n",
       "      <td>12.3778</td>\n",
       "      <td>4.6961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Bream</td>\n",
       "      <td>363.0</td>\n",
       "      <td>26.3</td>\n",
       "      <td>29.0</td>\n",
       "      <td>33.5</td>\n",
       "      <td>12.7300</td>\n",
       "      <td>4.4555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Bream</td>\n",
       "      <td>430.0</td>\n",
       "      <td>26.5</td>\n",
       "      <td>29.0</td>\n",
       "      <td>34.0</td>\n",
       "      <td>12.4440</td>\n",
       "      <td>5.1340</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Species  Weight  Length1  Length2  Length3   Height   Width\n",
       "0   Bream   242.0     23.2     25.4     30.0  11.5200  4.0200\n",
       "1   Bream   290.0     24.0     26.3     31.2  12.4800  4.3056\n",
       "2   Bream   340.0     23.9     26.5     31.1  12.3778  4.6961\n",
       "3   Bream   363.0     26.3     29.0     33.5  12.7300  4.4555\n",
       "4   Bream   430.0     26.5     29.0     34.0  12.4440  5.1340"
      ]
     },
     "execution_count": 229,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fish.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 981,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 1008x1152 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 55932 characters]\n",
      "text/plain": [
       "<Figure size 660.975x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(14,16))\n",
    "sns.relplot(x=\"Width\" , y=\"Height\" , hue=\"Species\" ,data=fish , height=8 , aspect=1)\n",
    "plt.gcf().text(.5, .99, \"Rel Plot\", fontsize = 40, color='Black' ,ha='center', va='center')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 231,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 720x720 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 109588 characters]\n",
      "text/plain": [
       "<Figure size 1337.6x360 with 7 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "plt.figure(figsize=(10,10))\n",
    "sns.set(rc={'xtick.labelsize':12,'ytick.labelsize':10,'axes.labelsize':10  , \"axes.grid\":False})\n",
    "sns.relplot(x=\"Period\" , y=\"Unemployed\" , hue=\"Gender\" , col=\"Age\",kind='line', height=5, \n",
    "            aspect=.5 ,data=employment)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 232,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 263648 characters]\n",
      "text/plain": [
       "<Figure size 1805.6x864 with 7 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "sns.set(rc={'xtick.labelsize':16,'ytick.labelsize':16,'axes.labelsize':16  , \"axes.grid\":False})\n",
    "sns.relplot(x=\"Period\" , y=\"Unemployed\" , hue=\"Gender\" , col=\"Age\",kind='line', height=6, \n",
    "            aspect=1 ,data=employment, col_wrap = 4 , linewidth =2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 233,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>sex</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>smoker</th>\n",
       "      <th>region</th>\n",
       "      <th>charges</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "      <td>southwest</td>\n",
       "      <td>16884.92400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>1725.55230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>male</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>4449.46200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>male</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>21984.47061</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>male</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>3866.85520</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     sex     bmi  children smoker     region      charges\n",
       "0   19  female  27.900         0    yes  southwest  16884.92400\n",
       "1   18    male  33.770         1     no  southeast   1725.55230\n",
       "2   28    male  33.000         3     no  southeast   4449.46200\n",
       "3   33    male  22.705         0     no  northwest  21984.47061\n",
       "4   32    male  28.880         0     no  northwest   3866.85520"
      ]
     },
     "execution_count": 233,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insurance.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 234,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x1edd254a6d8>"
      ]
     },
     "execution_count": 234,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 278660 characters]\n",
      "text/plain": [
       "<Figure size 792.85x1440 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns and rows to show a categorical variable using \"col\" and \"row\" parameter\n",
    "sns.set(rc={'xtick.labelsize':12,'ytick.labelsize':12,'axes.labelsize':12  , \"axes.grid\":False})\n",
    "sns.relplot(x=\"bmi\", y=\"charges\", hue=\"sex\",\n",
    "                col=\"sex\", row=\"region\", data=insurance)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 971,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x1edd9586320>"
      ]
     },
     "execution_count": 971,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 277160 characters]\n",
      "text/plain": [
       "<Figure size 1282.45x1008 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns and rows to show a categorical variable using \"col\" and \"row\" parameter\n",
    "sns.set(rc={'xtick.labelsize':14,'ytick.labelsize':14,'axes.labelsize':14  , \"axes.grid\":False})\n",
    "sns.relplot(x=\"bmi\", y=\"charges\", hue=\"sex\",height=7, aspect=.6,\n",
    "                col=\"region\", row=\"sex\", data=insurance)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 236,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Period</th>\n",
       "      <th>Unemployed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>177</th>\n",
       "      <td>25 to 34 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2006-01-01</td>\n",
       "      <td>92000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>178</th>\n",
       "      <td>35 to 44 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2006-01-01</td>\n",
       "      <td>134000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>179</th>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2006-01-01</td>\n",
       "      <td>110000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>180</th>\n",
       "      <td>55 to 64 years</td>\n",
       "      <td>Women</td>\n",
       "      <td>2006-01-01</td>\n",
       "      <td>85000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>181</th>\n",
       "      <td>65 years and over</td>\n",
       "      <td>Women</td>\n",
       "      <td>2006-01-01</td>\n",
       "      <td>61000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Age Gender     Period  Unemployed\n",
       "177     25 to 34 years  Women 2006-01-01       92000\n",
       "178     35 to 44 years  Women 2006-01-01      134000\n",
       "179     45 to 54 years  Women 2006-01-01      110000\n",
       "180     55 to 64 years  Women 2006-01-01       85000\n",
       "181  65 years and over  Women 2006-01-01       61000"
      ]
     },
     "execution_count": 236,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "emp.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 237,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x1edd56add30>"
      ]
     },
     "execution_count": 237,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 224068 characters]\n",
      "text/plain": [
       "<Figure size 1157.6x1080 with 7 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Limiting the number of columns using \"col_wrap\"\n",
    "sns.relplot(x=\"Period\", y=\"Unemployed\", hue=\"Gender\",col=\"Age\" , col_wrap=3,kind=\"line\",linewidth = 2,\n",
    "            height=5, aspect=1, estimator=None, data=employment)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Bar Plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Bar Plot shows the relationship between a numerical variable and a categorical variable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 731,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 239,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 16588 characters]\n",
      "text/plain": [
       "<Figure size 1440x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,7))\n",
    "sns.barplot(x=pokemon['Type 1'], y= pokemon['Attack'])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As per the above Bar plot pokemon with Type-1 as $Dragon$ are best attackers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 240,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 17152 characters]\n",
      "text/plain": [
       "<Figure size 1440x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,7))\n",
    "sns.barplot(x=pokemon['Type 1'], y= pokemon['Defense'])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 241,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 17120 characters]\n",
      "text/plain": [
       "<Figure size 1440x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Sorted Bar plot\n",
    "plt.figure(figsize=(20,7))\n",
    "order = pokemon.groupby(['Type 1']).mean().sort_values('Defense' , ascending = False).index.values\n",
    "sns.barplot(x=pokemon['Type 1'], y= pokemon['Defense'] , order=order)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Pokemon with Type-2 as Steel have best defence"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 242,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 16540 characters]\n",
      "text/plain": [
       "<Figure size 1440x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,7))\n",
    "sns.barplot(x=pokemon['Type 1'], y= pokemon['Speed'])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Pokemons with Type-1 as Flying are the fastest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 243,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 19496 characters]\n",
      "text/plain": [
       "<Figure size 576x720 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Horizontal Bar plot\n",
    "plt.figure(figsize=(8,10))\n",
    "sns.barplot(x=pokemon['Speed'], y= pokemon['Type 1'])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 244,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 17444 characters]\n",
      "text/plain": [
       "<Figure size 792x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(11,7))\n",
    "sns.barplot(x=\"Age\",y=\"Unemployed\", data=employment)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 245,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14916 characters]\n",
      "text/plain": [
       "<Figure size 1440x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,7))\n",
    "sns.countplot(x=pokemon['Type 1'])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 246,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14908 characters]\n",
      "text/plain": [
       "<Figure size 1440x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,7))\n",
    "sns.countplot(x=pokemon['Type 1'] , order = pokemon['Type 1'].value_counts().index)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Pokemon with Type-1 as water & Normal are most common."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 247,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 20208 characters]\n",
      "text/plain": [
       "<Figure size 1440x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Changing the background of bar plot\n",
    "plt.figure(figsize=(20,7))\n",
    "sns.set(rc={\"axes.facecolor\":\"#283747\", \"axes.grid\":False,'xtick.labelsize':14,'ytick.labelsize':14})\n",
    "sns.countplot(x=pokemon['Type 1'] , order = pokemon['Type 1'].value_counts().index)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 991,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 31704 characters]\n",
      "text/plain": [
       "<Figure size 1440x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,7))\n",
    "sns.set(rc={\"axes.facecolor\":\"#283747\", \"axes.grid\":False,'xtick.labelsize':14,'ytick.labelsize':14})\n",
    "plt.gcf().text(.5, .93, \"Bar Plot\", fontsize = 60, color='Black' ,ha='center', va='center')\n",
    "sns.countplot(x=pokemon['Type 1'] , order = pokemon['Type 1'].value_counts().index , palette=\"spring\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 249,
   "metadata": {},
   "outputs": [],
   "source": [
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 250,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 15004 characters]\n",
      "text/plain": [
       "<Figure size 1440x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,7))\n",
    "sns.countplot(x=pokemon['Type 2'])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As per above Count plot Type-2 Flying pokemon are most common"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 251,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>diet</th>\n",
       "      <th>pulse</th>\n",
       "      <th>time</th>\n",
       "      <th>kind</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>85</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>85</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>88</td>\n",
       "      <td>30 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>90</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>92</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id     diet  pulse    time  kind\n",
       "0   1  low fat     85   1 min  rest\n",
       "1   1  low fat     85  15 min  rest\n",
       "2   1  low fat     88  30 min  rest\n",
       "3   2  low fat     90   1 min  rest\n",
       "4   2  low fat     92  15 min  rest"
      ]
     },
     "execution_count": 251,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "exercise.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 252,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 10232 characters]\n",
      "text/plain": [
       "<Figure size 576x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\"\n",
    "plt.figure(figsize=(8,6))\n",
    "sns.barplot(x=exercise.kind , y=exercise.pulse ,hue=exercise.diet)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 253,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ticket</th>\n",
       "      <th>requestor</th>\n",
       "      <th>RequestorSeniority</th>\n",
       "      <th>ITOwner</th>\n",
       "      <th>FiledAgainst</th>\n",
       "      <th>TicketType</th>\n",
       "      <th>Severity</th>\n",
       "      <th>Priority</th>\n",
       "      <th>daysOpen</th>\n",
       "      <th>Satisfaction</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1929</td>\n",
       "      <td>1 - Junior</td>\n",
       "      <td>50</td>\n",
       "      <td>Systems</td>\n",
       "      <td>Issue</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>3</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1587</td>\n",
       "      <td>2 - Regular</td>\n",
       "      <td>15</td>\n",
       "      <td>Software</td>\n",
       "      <td>Request</td>\n",
       "      <td>1 - Minor</td>\n",
       "      <td>1 - Low</td>\n",
       "      <td>5</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>925</td>\n",
       "      <td>2 - Regular</td>\n",
       "      <td>15</td>\n",
       "      <td>Access/Login</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>0</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>413</td>\n",
       "      <td>4 - Management</td>\n",
       "      <td>22</td>\n",
       "      <td>Systems</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>20</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>318</td>\n",
       "      <td>1 - Junior</td>\n",
       "      <td>22</td>\n",
       "      <td>Access/Login</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>1 - Low</td>\n",
       "      <td>1</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ticket  requestor RequestorSeniority  ITOwner  FiledAgainst TicketType  \\\n",
       "0       1       1929         1 - Junior       50       Systems      Issue   \n",
       "1       2       1587        2 - Regular       15      Software    Request   \n",
       "2       3        925        2 - Regular       15  Access/Login    Request   \n",
       "3       4        413     4 - Management       22       Systems    Request   \n",
       "4       5        318         1 - Junior       22  Access/Login    Request   \n",
       "\n",
       "     Severity        Priority  daysOpen     Satisfaction  \n",
       "0  2 - Normal  0 - Unassigned         3  1 - Unsatisfied  \n",
       "1   1 - Minor         1 - Low         5  1 - Unsatisfied  \n",
       "2  2 - Normal  0 - Unassigned         0      0 - Unknown  \n",
       "3  2 - Normal  0 - Unassigned        20      0 - Unknown  \n",
       "4  2 - Normal         1 - Low         1  1 - Unsatisfied  "
      ]
     },
     "execution_count": 253,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "helpdesk.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 254,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 17312 characters]\n",
      "text/plain": [
       "<Figure size 720x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\"\n",
    "plt.figure(figsize=(10,6))\n",
    "sns.barplot(x=helpdesk.TicketType , y=helpdesk.daysOpen , hue=helpdesk.FiledAgainst)\n",
    "sns.despine()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Cat Plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Cat Plot provides access to several axes-level functions (\"point\", \"bar\", \"strip\", \"swarm\",\"box\", \"violin\", \"count\" or \"boxen\") that show the relationship between a numerical and one or more categorical variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 255,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14160 characters]\n",
      "text/plain": [
       "<Figure size 360x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Use Count Plot to visualize data\n",
    "sns.catplot(y = \"Type 1\", kind = \"count\",data = pokemon)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 256,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14248 characters]\n",
      "text/plain": [
       "<Figure size 360x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Sorted Count Plot\n",
    "sns.catplot(y = \"Type 1\", kind = \"count\",data = pokemon , order=pokemon['Type 1'].value_counts().index)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 257,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 504x504 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 19292 characters]\n",
      "text/plain": [
       "<Figure size 360x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Use Voilin Plot to visualize data\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.catplot(x=\"species\" , y = \"petal_width\" ,kind=\"violin\" ,data=iris)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 258,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 792x648 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 23176 characters]\n",
      "text/plain": [
       "<Figure size 720x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(11,9))\n",
    "sns.catplot(x = \"petal_width\" , y=\"species\" ,kind=\"violin\" ,data=iris ,\n",
    "            height=5, aspect=2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 259,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>diet</th>\n",
       "      <th>pulse</th>\n",
       "      <th>time</th>\n",
       "      <th>kind</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>85</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>85</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>88</td>\n",
       "      <td>30 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>90</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>92</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id     diet  pulse    time  kind\n",
       "0   1  low fat     85   1 min  rest\n",
       "1   1  low fat     85  15 min  rest\n",
       "2   1  low fat     88  30 min  rest\n",
       "3   2  low fat     90   1 min  rest\n",
       "4   2  low fat     92  15 min  rest"
      ]
     },
     "execution_count": 259,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "exercise.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 260,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x1edd1e14be0>"
      ]
     },
     "execution_count": 260,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 22012 characters]\n",
      "text/plain": [
       "<Figure size 720x360 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "sns.catplot(x='kind' , y='pulse' , data=exercise , col=\"diet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 261,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ticket</th>\n",
       "      <th>requestor</th>\n",
       "      <th>RequestorSeniority</th>\n",
       "      <th>ITOwner</th>\n",
       "      <th>FiledAgainst</th>\n",
       "      <th>TicketType</th>\n",
       "      <th>Severity</th>\n",
       "      <th>Priority</th>\n",
       "      <th>daysOpen</th>\n",
       "      <th>Satisfaction</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1929</td>\n",
       "      <td>1 - Junior</td>\n",
       "      <td>50</td>\n",
       "      <td>Systems</td>\n",
       "      <td>Issue</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>3</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1587</td>\n",
       "      <td>2 - Regular</td>\n",
       "      <td>15</td>\n",
       "      <td>Software</td>\n",
       "      <td>Request</td>\n",
       "      <td>1 - Minor</td>\n",
       "      <td>1 - Low</td>\n",
       "      <td>5</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>925</td>\n",
       "      <td>2 - Regular</td>\n",
       "      <td>15</td>\n",
       "      <td>Access/Login</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>0</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>413</td>\n",
       "      <td>4 - Management</td>\n",
       "      <td>22</td>\n",
       "      <td>Systems</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>20</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>318</td>\n",
       "      <td>1 - Junior</td>\n",
       "      <td>22</td>\n",
       "      <td>Access/Login</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>1 - Low</td>\n",
       "      <td>1</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ticket  requestor RequestorSeniority  ITOwner  FiledAgainst TicketType  \\\n",
       "0       1       1929         1 - Junior       50       Systems      Issue   \n",
       "1       2       1587        2 - Regular       15      Software    Request   \n",
       "2       3        925        2 - Regular       15  Access/Login    Request   \n",
       "3       4        413     4 - Management       22       Systems    Request   \n",
       "4       5        318         1 - Junior       22  Access/Login    Request   \n",
       "\n",
       "     Severity        Priority  daysOpen     Satisfaction  \n",
       "0  2 - Normal  0 - Unassigned         3  1 - Unsatisfied  \n",
       "1   1 - Minor         1 - Low         5  1 - Unsatisfied  \n",
       "2  2 - Normal  0 - Unassigned         0      0 - Unknown  \n",
       "3  2 - Normal  0 - Unassigned        20      0 - Unknown  \n",
       "4  2 - Normal         1 - Low         1  1 - Unsatisfied  "
      ]
     },
     "execution_count": 261,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "helpdesk.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 738,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 1440x720 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 24576 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 4 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\" Facet along the columns to show a categorical variable using \"col\" parameter and \n",
    "Limiting the number of columns using \"col_wrap\" \"\"\"\n",
    "\n",
    "plt.figure(figsize=(20,10))\n",
    "sns.catplot(\"Priority\", col=\"FiledAgainst\",col_wrap=2,\n",
    "                data=helpdesk,kind=\"count\",height=5, aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 263,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Period</th>\n",
       "      <th>Unemployed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>16 to 19 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>91000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20 to 24 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>175000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>25 to 34 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>194000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>35 to 44 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>201000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>207000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Age Gender     Period  Unemployed\n",
       "0  16 to 19 years    Men 2005-01-01       91000\n",
       "1  20 to 24 years    Men 2005-01-01      175000\n",
       "2  25 to 34 years    Men 2005-01-01      194000\n",
       "3  35 to 44 years    Men 2005-01-01      201000\n",
       "4  45 to 54 years    Men 2005-01-01      207000"
      ]
     },
     "execution_count": 263,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employment.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 729,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 39264 characters]\n",
      "text/plain": [
       "<Figure size 1512x432 with 7 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "sns.set(rc={'xtick.labelsize':15,'ytick.labelsize':15,'axes.labelsize':15 , \"axes.facecolor\":\"#f2eee3\" , \"axes.grid\":False})\n",
    "sns.catplot(x=\"Gender\", y=\"Unemployed\", col=\"Age\",data=employment,kind=\"bar\",height=6 , aspect=.5 ,  palette=\"bright\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Dist Plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Dist plot is used to plot a univariate distribution of observations."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 740,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 269,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14684 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "num = np.random.normal(1,10,1000)\n",
    "sns.distplot(num)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 270,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14684 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.distplot(num,kde=True) # Histogram with a kernel density estimate (Density Curve)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 271,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 5668 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.distplot(num,kde=False) # Histogram without a kernel density estimate (Density Curve)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 272,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 6772 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.distplot(num,kde=False,rug=True) # Histogram with Rugplot\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 273,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 17976 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.distplot(num,kde=True,rug=True,hist=False) # Histogram with Rugplot & KDE\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 274,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>longitude</th>\n",
       "      <th>latitude</th>\n",
       "      <th>housing_median_age</th>\n",
       "      <th>total_rooms</th>\n",
       "      <th>total_bedrooms</th>\n",
       "      <th>population</th>\n",
       "      <th>households</th>\n",
       "      <th>median_income</th>\n",
       "      <th>median_house_value</th>\n",
       "      <th>ocean_proximity</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-122.23</td>\n",
       "      <td>37.88</td>\n",
       "      <td>41.0</td>\n",
       "      <td>880.0</td>\n",
       "      <td>129.0</td>\n",
       "      <td>322.0</td>\n",
       "      <td>126.0</td>\n",
       "      <td>8.3252</td>\n",
       "      <td>452600.0</td>\n",
       "      <td>NEAR BAY</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-122.22</td>\n",
       "      <td>37.86</td>\n",
       "      <td>21.0</td>\n",
       "      <td>7099.0</td>\n",
       "      <td>1106.0</td>\n",
       "      <td>2401.0</td>\n",
       "      <td>1138.0</td>\n",
       "      <td>8.3014</td>\n",
       "      <td>358500.0</td>\n",
       "      <td>NEAR BAY</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-122.24</td>\n",
       "      <td>37.85</td>\n",
       "      <td>52.0</td>\n",
       "      <td>1467.0</td>\n",
       "      <td>190.0</td>\n",
       "      <td>496.0</td>\n",
       "      <td>177.0</td>\n",
       "      <td>7.2574</td>\n",
       "      <td>352100.0</td>\n",
       "      <td>NEAR BAY</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-122.25</td>\n",
       "      <td>37.85</td>\n",
       "      <td>52.0</td>\n",
       "      <td>1274.0</td>\n",
       "      <td>235.0</td>\n",
       "      <td>558.0</td>\n",
       "      <td>219.0</td>\n",
       "      <td>5.6431</td>\n",
       "      <td>341300.0</td>\n",
       "      <td>NEAR BAY</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-122.25</td>\n",
       "      <td>37.85</td>\n",
       "      <td>52.0</td>\n",
       "      <td>1627.0</td>\n",
       "      <td>280.0</td>\n",
       "      <td>565.0</td>\n",
       "      <td>259.0</td>\n",
       "      <td>3.8462</td>\n",
       "      <td>342200.0</td>\n",
       "      <td>NEAR BAY</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   longitude  latitude  housing_median_age  total_rooms  total_bedrooms  \\\n",
       "0    -122.23     37.88                41.0        880.0           129.0   \n",
       "1    -122.22     37.86                21.0       7099.0          1106.0   \n",
       "2    -122.24     37.85                52.0       1467.0           190.0   \n",
       "3    -122.25     37.85                52.0       1274.0           235.0   \n",
       "4    -122.25     37.85                52.0       1627.0           280.0   \n",
       "\n",
       "   population  households  median_income  median_house_value ocean_proximity  \n",
       "0       322.0       126.0         8.3252            452600.0        NEAR BAY  \n",
       "1      2401.0      1138.0         8.3014            358500.0        NEAR BAY  \n",
       "2       496.0       177.0         7.2574            352100.0        NEAR BAY  \n",
       "3       558.0       219.0         5.6431            341300.0        NEAR BAY  \n",
       "4       565.0       259.0         3.8462            342200.0        NEAR BAY  "
      ]
     },
     "execution_count": 274,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Housing Dataset\n",
    "housing.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 275,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 67940 characters]\n",
      "text/plain": [
       "<Figure size 1440x1440 with 9 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "housing.hist(bins=40 , figsize=(20,20)) #Pandas Hist function\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 276,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 25172 characters]\n",
      "text/plain": [
       "<Figure size 792x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(11,7))\n",
    "sns.distplot( housing[\"median_income\"])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 277,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 25176 characters]\n",
      "text/plain": [
       "<Figure size 792x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(11,7))\n",
    "sns.distplot( housing[\"median_income\"] , bins=20)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 278,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 26060 characters]\n",
      "text/plain": [
       "<Figure size 792x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(11,7))\n",
    "sns.distplot( housing[\"median_income\"] ,bins=20 , hist_kws=dict(edgecolor = '#9dab86' ,linewidth=2))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 755,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 28876 characters]\n",
      "text/plain": [
       "<Figure size 792x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Changing the color of all the plot elements using \"color\" parameter\n",
    "plt.figure(figsize=(11,7))\n",
    "sns.distplot( housing[\"median_income\"] ,bins=20 , hist_kws=dict(edgecolor = '#9dab86' ,linewidth=2) , color='green')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 741,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.set(style=\"white\", color_codes=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 742,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 169568 characters]\n",
      "text/plain": [
       "<Figure size 1440x1440 with 9 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Displaying multiple distplots using subplot function. \n",
    "fig1 , axes = plt.subplots(nrows=3,ncols=3 , figsize = (20,20))\n",
    "sns.distplot( housing[\"longitude\"] , ax=axes[0, 0])\n",
    "sns.distplot( housing[\"latitude\"] ,  ax=axes[0, 1])\n",
    "sns.distplot( housing[\"housing_median_age\"] , ax=axes[0, 2])\n",
    "sns.distplot( housing[\"total_rooms\"], ax=axes[1, 0] )\n",
    "sns.distplot( housing[\"population\"] , ax=axes[1, 1] )\n",
    "sns.distplot( housing[\"households\"] , ax=axes[1, 2] )\n",
    "sns.distplot( housing[\"median_income\"] , ax=axes[2, 0])\n",
    "sns.distplot( housing[\"median_house_value\"], ax=axes[2, 1])\n",
    "sns.distplot( housing[\"median_house_value\"], ax=axes[2, 2])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 754,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 73356 characters]\n",
      "text/plain": [
       "<Figure size 1440x1440 with 9 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Displaying multiple distplots using subplot function. \n",
    "fig1 , axes = plt.subplots(nrows=3,ncols=3 , figsize = (20,20))\n",
    "sns.distplot( housing[\"longitude\"] , color=\"#00bcd4\", ax=axes[0, 0] , kde=False , bins=20)\n",
    "sns.distplot( housing[\"latitude\"] , color=\"#937d14\", ax=axes[0, 1] , kde=False,bins=20)\n",
    "sns.distplot( housing[\"housing_median_age\"] , color=\"#006600\", ax=axes[0, 2],kde=False,bins=20)\n",
    "sns.distplot( housing[\"total_rooms\"] , color=\"#ff1e56\", ax=axes[1, 0] , kde=False,bins=20)\n",
    "sns.distplot( housing[\"population\"] , color=\"#216353\", ax=axes[1, 1] , kde=False,bins=20)\n",
    "sns.distplot( housing[\"households\"] , color=\"#FF8F00\", ax=axes[1, 2] , kde=False,bins=20)\n",
    "sns.distplot( housing[\"median_income\"] , color=\"#33FF00\", ax=axes[2, 0] , kde=False,bins=20)\n",
    "sns.distplot( housing[\"median_house_value\"] , color=\"#FF3300\", ax=axes[2, 1], kde=False,bins=20)\n",
    "sns.distplot( housing[\"median_house_value\"] , color=\"#CCCC00\", ax=axes[2, 2] , kde=False,bins=20)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# KDE PLOT"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### KDE Plot is used to estimate the probability density function of a continuous random variable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 281,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 94336 characters]\n",
      "text/plain": [
       "<Figure size 1008x1008 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.set_style(\"darkgrid\")\n",
    "fig1 , axes = plt.subplots(nrows=2,ncols=2 , figsize = (14,14))\n",
    "\n",
    "x = np.random.normal(1,10,1000)\n",
    "\n",
    "#Simple KDE Plot\n",
    "axes[0,0].set_title(\"Simple KDE Plot\")\n",
    "sns.kdeplot(x,ax=axes[0,0])\n",
    "\n",
    "\n",
    "# Shade under the density curve using the \"shade\" parameter\n",
    "axes[0,1].set_title(\"KDE Plot (Shaded Area Under the Curve)\")\n",
    "sns.kdeplot(x,shade=True,ax=axes[0,1])\n",
    "\n",
    "\n",
    "# Shade under the density curve using the \"shade\" parameter and use a different color.\n",
    "axes[1,0].set_title(\"KDE Plot (Different Color)\")\n",
    "sns.kdeplot(x,ax=axes[1,0],color = 'r',shade=True,cut=0)\n",
    "\n",
    "#Plotting the density on the vertical axis\n",
    "axes[1,1].set_title(\"KDE Plot (Density on Vertical Axis)\")\n",
    "sns.kdeplot(x,vertical=True)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 282,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1edd24ac7f0>"
      ]
     },
     "execution_count": 282,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 17100 characters]\n",
      "text/plain": [
       "<Figure size 432x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(6,8))\n",
    "x = np.linspace(0, 10, 100) \n",
    "y = np.sin(x)\n",
    "sns.kdeplot(x,y,shade=True,cmap=\"Reds\", shade_lowest=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 283,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>sex</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>smoker</th>\n",
       "      <th>region</th>\n",
       "      <th>charges</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "      <td>southwest</td>\n",
       "      <td>16884.92400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>1725.55230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>male</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>4449.46200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>male</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>21984.47061</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>male</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>3866.85520</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     sex     bmi  children smoker     region      charges\n",
       "0   19  female  27.900         0    yes  southwest  16884.92400\n",
       "1   18    male  33.770         1     no  southeast   1725.55230\n",
       "2   28    male  33.000         3     no  southeast   4449.46200\n",
       "3   33    male  22.705         0     no  northwest  21984.47061\n",
       "4   32    male  28.880         0     no  northwest   3866.85520"
      ]
     },
     "execution_count": 283,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insurance.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 284,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14852 characters]\n",
      "text/plain": [
       "<Figure size 432x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(6,8))\n",
    "sns.kdeplot(insurance.bmi,insurance.charges,shade=True,cmap=\"Reds\", shade_lowest=False)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 285,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14396 characters]\n",
      "text/plain": [
       "<Figure size 576x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "iris = sns.load_dataset(\"iris\")\n",
    "plt.figure(figsize=(8,6))\n",
    "sns.kdeplot(iris.sepal_width, iris.sepal_length,cmap=\"Reds\", shade=True, shade_lowest=False)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Swarm Plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Swarm plot is a categorical scatterplot with non-overlapping points"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline\n",
    "sns.set_style(\"white\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 287,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>sex</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>smoker</th>\n",
       "      <th>region</th>\n",
       "      <th>charges</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "      <td>southwest</td>\n",
       "      <td>16884.92400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>1725.55230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>male</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>4449.46200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>male</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>21984.47061</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>male</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>3866.85520</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     sex     bmi  children smoker     region      charges\n",
       "0   19  female  27.900         0    yes  southwest  16884.92400\n",
       "1   18    male  33.770         1     no  southeast   1725.55230\n",
       "2   28    male  33.000         3     no  southeast   4449.46200\n",
       "3   33    male  22.705         0     no  northwest  21984.47061\n",
       "4   32    male  28.880         0     no  northwest   3866.85520"
      ]
     },
     "execution_count": 287,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insurance.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 288,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 75288 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Simple Swarm plot\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.swarmplot(x=insurance.smoker, y=insurance.charges)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 289,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 72620 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Draw horizontal swarm plot\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.swarmplot(x=insurance.charges , y=insurance.smoker)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 290,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 27620 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(7,7))\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_width\" ,data=iris , size=6)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 291,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 138584 characters]\n",
      "text/plain": [
       "<Figure size 1440x1440 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Displaying multiple swarmplots using subplot function. \n",
    "fig1 , axes = plt.subplots(nrows=2,ncols=2 , figsize = (20,20))\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_width\" , ax = axes[0,0] ,data=iris , size=8)\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_length\" ,ax = axes[0,1] , data=iris , size=8)\n",
    "sns.swarmplot(x=\"species\" , y = \"sepal_width\" , ax = axes[1,0] , data=iris, size=8)\n",
    "sns.swarmplot(x=\"species\" , y = \"sepal_length\" , ax = axes[1,1] , data=iris , size=8)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 292,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>diet</th>\n",
       "      <th>pulse</th>\n",
       "      <th>time</th>\n",
       "      <th>kind</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>85</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>85</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>88</td>\n",
       "      <td>30 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>90</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>92</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id     diet  pulse    time  kind\n",
       "0   1  low fat     85   1 min  rest\n",
       "1   1  low fat     85  15 min  rest\n",
       "2   1  low fat     88  30 min  rest\n",
       "3   2  low fat     90   1 min  rest\n",
       "4   2  low fat     92  15 min  rest"
      ]
     },
     "execution_count": 292,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "exercise.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 293,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1edd243b6d8>"
      ]
     },
     "execution_count": 293,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 20560 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(7,7))\n",
    "sns.swarmplot(x= \"kind\",  y = \"pulse\", data = exercise)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 294,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1edd6ec0898>"
      ]
     },
     "execution_count": 294,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 30316 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing size of data points using \"size\"parameter\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.swarmplot(x= \"kind\",  y = \"pulse\", size = 9, data = exercise)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 295,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1edd243b7b8>"
      ]
     },
     "execution_count": 295,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 51076 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Changing edge color , size and linewidth of data points\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.swarmplot(x= \"kind\",  y = \"pulse\", size = 9 , linewidth= 2 , edgecolor=\"black\" , data = exercise)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 296,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1edd168e668>"
      ]
     },
     "execution_count": 296,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 29972 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\"\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.swarmplot(x= \"kind\",  y = \"pulse\", hue=\"diet\", size = 8 , data = exercise)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 297,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Period</th>\n",
       "      <th>Unemployed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>16 to 19 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>91000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20 to 24 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>175000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>25 to 34 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>194000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>35 to 44 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>201000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Men</td>\n",
       "      <td>2005-01-01</td>\n",
       "      <td>207000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Age Gender     Period  Unemployed\n",
       "0  16 to 19 years    Men 2005-01-01       91000\n",
       "1  20 to 24 years    Men 2005-01-01      175000\n",
       "2  25 to 34 years    Men 2005-01-01      194000\n",
       "3  35 to 44 years    Men 2005-01-01      201000\n",
       "4  45 to 54 years    Men 2005-01-01      207000"
      ]
     },
     "execution_count": 297,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "employment.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 298,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 170644 characters]\n",
      "text/plain": [
       "<Figure size 792x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(11,8))\n",
    "sns.swarmplot(x=employment.Age ,palette=\"Set1\", y = employment.Unemployed)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 299,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 209916 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "sns.set(rc={'xtick.labelsize':10,'ytick.labelsize':10,'axes.labelsize':14})\n",
    "sns.set_style(\"white\")\n",
    "sns.catplot(x=\"Age\" , y = \"Unemployed\" , col= \"Gender\" , data=employment, kind=\"swarm\" , height=8, aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>#</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type 1</th>\n",
       "      <th>Type 2</th>\n",
       "      <th>HP</th>\n",
       "      <th>Attack</th>\n",
       "      <th>Defense</th>\n",
       "      <th>Sp. Atk</th>\n",
       "      <th>Sp. Def</th>\n",
       "      <th>Speed</th>\n",
       "      <th>Generation</th>\n",
       "      <th>Legendary</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Bulbasaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>45</td>\n",
       "      <td>49</td>\n",
       "      <td>49</td>\n",
       "      <td>65</td>\n",
       "      <td>65</td>\n",
       "      <td>45</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>318</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Ivysaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>60</td>\n",
       "      <td>62</td>\n",
       "      <td>63</td>\n",
       "      <td>80</td>\n",
       "      <td>80</td>\n",
       "      <td>60</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Venusaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>80</td>\n",
       "      <td>82</td>\n",
       "      <td>83</td>\n",
       "      <td>100</td>\n",
       "      <td>100</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>525</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>VenusaurMega Venusaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>80</td>\n",
       "      <td>100</td>\n",
       "      <td>123</td>\n",
       "      <td>122</td>\n",
       "      <td>120</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>Charmander</td>\n",
       "      <td>Fire</td>\n",
       "      <td>NaN</td>\n",
       "      <td>39</td>\n",
       "      <td>52</td>\n",
       "      <td>43</td>\n",
       "      <td>60</td>\n",
       "      <td>50</td>\n",
       "      <td>65</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>309</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   #                   Name Type 1  Type 2  HP  Attack  Defense  Sp. Atk  \\\n",
       "0  1              Bulbasaur  Grass  Poison  45      49       49       65   \n",
       "1  2                Ivysaur  Grass  Poison  60      62       63       80   \n",
       "2  3               Venusaur  Grass  Poison  80      82       83      100   \n",
       "3  3  VenusaurMega Venusaur  Grass  Poison  80     100      123      122   \n",
       "4  4             Charmander   Fire     NaN  39      52       43       60   \n",
       "\n",
       "   Sp. Def  Speed  Generation  Legendary  Total  \n",
       "0       65     45           1      False    318  \n",
       "1       80     60           1      False    405  \n",
       "2      100     80           1      False    525  \n",
       "3      120     80           1      False    625  \n",
       "4       50     65           1      False    309  "
      ]
     },
     "execution_count": 130,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pokemon.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['#', 'Name', 'Type 1', 'Type 2', 'HP', 'Attack', 'Defense', 'Sp. Atk',\n",
       "       'Sp. Def', 'Speed', 'Generation', 'Legendary', 'Total'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 131,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pokemon.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>HP</th>\n",
       "      <th>Attack</th>\n",
       "      <th>Defense</th>\n",
       "      <th>Sp. Atk</th>\n",
       "      <th>Sp. Def</th>\n",
       "      <th>Speed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>45</td>\n",
       "      <td>49</td>\n",
       "      <td>49</td>\n",
       "      <td>65</td>\n",
       "      <td>65</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>60</td>\n",
       "      <td>62</td>\n",
       "      <td>63</td>\n",
       "      <td>80</td>\n",
       "      <td>80</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>80</td>\n",
       "      <td>82</td>\n",
       "      <td>83</td>\n",
       "      <td>100</td>\n",
       "      <td>100</td>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>80</td>\n",
       "      <td>100</td>\n",
       "      <td>123</td>\n",
       "      <td>122</td>\n",
       "      <td>120</td>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>39</td>\n",
       "      <td>52</td>\n",
       "      <td>43</td>\n",
       "      <td>60</td>\n",
       "      <td>50</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   HP  Attack  Defense  Sp. Atk  Sp. Def  Speed\n",
       "0  45      49       49       65       65     45\n",
       "1  60      62       63       80       80     60\n",
       "2  80      82       83      100      100     80\n",
       "3  80     100      123      122      120     80\n",
       "4  39      52       43       60       50     65"
      ]
     },
     "execution_count": 136,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pokemon1 = pokemon[[ 'HP', 'Attack', 'Defense', 'Sp. Atk','Sp. Def', 'Speed']]\n",
    "pokemon1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 351092 characters]\n",
      "text/plain": [
       "<Figure size 1008x864 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(14,12))\n",
    "sns.swarmplot(data=pokemon1,size=6)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Violin Plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Violinplots summarize numeric data over a set of categories.Violin plots are similar to box plots, except that they also show the probability density of the data at different values, usually smoothed by a kernel density estimator."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 759,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline\n",
    "sns.set_style(\"white\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 760,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 24424 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Simple Violin Plot\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.violinplot(x=\"species\" , y = \"petal_width\" ,data=iris)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 763,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 24436 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Drawing the quartiles as horizontal lines instead of a mini-box using (inner=\"quartile\")\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.violinplot(x=\"species\" , y = \"petal_width\" ,data=iris , inner=\"quartile\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 767,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23768 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Remove interior section of the Violin plot\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.violinplot(x=\"species\" , y = \"petal_width\" ,data=iris , inner=None)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 765,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 24344 characters]\n",
      "text/plain": [
       "<Figure size 648x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# horizontal violin plot\n",
    "plt.figure(figsize=(9,7))\n",
    "sns.violinplot(y=\"species\" , x = \"petal_width\" ,data=iris , inner=None)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 320,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 59244 characters]\n",
      "text/plain": [
       "<Figure size 1152x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Muted palette\n",
    "plt.figure(figsize=(16,7))\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , palette=\"muted\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 321,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 76252 characters]\n",
      "text/plain": [
       "<Figure size 1152x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Scale the density relative to the counts across all bins\n",
    "plt.figure(figsize=(16,7))\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , palette=\"Set1\" , scale=\"count\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 768,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 74668 characters]\n",
      "text/plain": [
       "<Figure size 1152x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Adjust the bandwidth of the KDE filtering parameter using \"bw\"\n",
    "plt.figure(figsize=(16,7))\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , palette=\"Set1\" , scale=\"count\" , bw=5)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 774,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 77788 characters]\n",
      "text/plain": [
       "<Figure size 1152x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Adjust the bandwidth of the KDE filtering parameter using \"bw\"\n",
    "plt.figure(figsize=(16,7))\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , palette=\"Set1\" , scale=\"count\" , bw=.2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 323,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 68760 characters]\n",
      "text/plain": [
       "<Figure size 1152x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Limit the violin range within the range of the observed data using \"cut =0\"\n",
    "plt.figure(figsize=(16,7))\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , palette=\"Set1\" , scale=\"count\" , cut=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 324,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 94900 characters]\n",
      "text/plain": [
       "<Figure size 1152x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Show groups with different colors using \"hue\" and \"palette\"\n",
    "plt.figure(figsize=(16,7))\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , hue= employment.Gender , palette=\"Set2\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 325,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 111504 characters]\n",
      "text/plain": [
       "<Figure size 1296x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Overlap the violinplots for different hue levels along the categorical axis using \"dodge=False\"\n",
    "plt.figure(figsize=(18,9))\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , hue= employment.Gender , palette=\"Set2\" , dodge=False)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 326,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 72948 characters]\n",
      "text/plain": [
       "<Figure size 1152x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Drawing split violins to compare across the hue variable using -> (split=True)\n",
    "plt.figure(figsize=(16,7))\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , hue= employment.Gender , palette=\"Set2\" , split=True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 327,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 75388 characters]\n",
      "text/plain": [
       "<Figure size 1152x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(16,7))\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , hue= employment.Gender , \n",
    "               palette=\"Set2\" , split=True , inner=\"quartile\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 328,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 102536 characters]\n",
      "text/plain": [
       "<Figure size 1152x792 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Showing each observation with a stick inside the violin using -> (inner=\"stick\")\n",
    "plt.figure(figsize=(16,11))\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , hue= employment.Gender , \n",
    "               palette=\"Set2\" , split=True , inner=\"stick\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 329,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 131180 characters]\n",
      "text/plain": [
       "<Figure size 1440x1440 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Displaying multiple violin plots using subplot function. \n",
    "fig1 , axes = plt.subplots(nrows=2,ncols=2 , figsize = (20,20))\n",
    "sns.violinplot(x=\"species\" , y = \"petal_width\" , ax = axes[0,0] ,data=iris , inner=None)\n",
    "sns.violinplot(x=\"species\" , y = \"petal_length\" ,ax = axes[0,1] , data=iris , inner=None)\n",
    "sns.violinplot(x=\"species\" , y = \"sepal_width\" , ax = axes[1,0] , data=iris, inner=None)\n",
    "sns.violinplot(x=\"species\" , y = \"sepal_length\" , ax = axes[1,1] , data=iris, inner=None )\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 330,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 214244 characters]\n",
      "text/plain": [
       "<Figure size 1440x1440 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Displaying swarmplot on top of violin plot\n",
    "fig1 , axes = plt.subplots(nrows=2,ncols=2 , figsize = (20,20))\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_width\" , ax = axes[0,0] ,data=iris , size=6 , color=\"white\")\n",
    "sns.violinplot(x=\"species\" , y = \"petal_width\" , ax = axes[0,0] ,data=iris , inner=None)\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_length\" ,ax = axes[0,1] , data=iris  , size=6 , color=\"white\")\n",
    "sns.violinplot(x=\"species\" , y = \"petal_length\" ,ax = axes[0,1] , data=iris , inner=None)\n",
    "sns.swarmplot(x=\"species\" , y = \"sepal_width\" , ax = axes[1,0] , data=iris , size=6 , color=\"white\")\n",
    "sns.violinplot(x=\"species\" , y = \"sepal_width\" , ax = axes[1,0] , data=iris, inner=None)\n",
    "sns.swarmplot(x=\"species\" , y = \"sepal_length\" , ax = axes[1,1] , data=iris , size=6 , color=\"white\")\n",
    "sns.violinplot(x=\"species\" , y = \"sepal_length\" , ax = axes[1,1] , data=iris, inner=None )\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 781,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 792x648 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 124844 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.catplot(x=\"Age\" , y = \"Unemployed\", col=\"Gender\", kind=\"violin\",palette=\"Set2\" , height=8, aspect=1 , \n",
    "            scale = \"count\",data=employment)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 332,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 792x648 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 114404 characters]\n",
      "text/plain": [
       "<Figure size 1263x576 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.catplot(x=\"parental level of education\" , y = \"math score\", hue= \"test preparation course\",\n",
    "            col=\"lunch\", kind=\"violin\",palette=\"Set3\" , height=8, aspect=1 ,data=stdperf , split = True , cut =0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Strip Plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Strip plot is a scatter plot where one of the variables is categorical."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 787,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline\n",
    "sns.set_style(\"white\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 788,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 80920 characters]\n",
      "text/plain": [
       "<Figure size 792x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(11,8))\n",
    "sns.stripplot(x=employment.Unemployed)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 789,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 101848 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(16,8))\n",
    "sns.stripplot(x=employment.Age ,palette=\"Set1\", y = employment.Unemployed)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 805,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 134700 characters]\n",
      "text/plain": [
       "<Figure size 1152x360 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\" \"Jitter\" parameter signifies the amount of jitter to apply. \n",
    "   This can be extremely useful when we have large clusters of data points\"\"\"\n",
    "\n",
    "plt.figure(figsize=(16,5))\n",
    "sns.stripplot(x=employment.Age ,palette=\"Set1\", y = employment.Unemployed , jitter=.3)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 303,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 83388 characters]\n",
      "text/plain": [
       "<Figure size 792x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Flip x and y inputs to make a horizontal strip plot\n",
    "plt.figure(figsize=(11,8))\n",
    "sns.stripplot(y=employment.Age ,palette=\"Set1\", x = employment.Unemployed , jitter=True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 304,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 160748 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(16,8))\n",
    "sns.stripplot(x=employment.Age ,palette=\"Set1\", y = employment.Unemployed , linewidth=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 305,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 353188 characters]\n",
      "text/plain": [
       "<Figure size 1152x720 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Adjust the linewidth of the edges of the circles using \"linewidth\" parameter\n",
    "# Adjust the size of the circles using the \"size\" parameter\n",
    "plt.figure(figsize=(16,10))\n",
    "sns.stripplot(x=employment.Age ,palette=\"Set1\", y = employment.Unemployed , linewidth=2, size=8 ,jitter=.3)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 306,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 134928 characters]\n",
      "text/plain": [
       "<Figure size 1152x720 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Using set2 pallete\n",
    "plt.figure(figsize=(16,10))\n",
    "sns.stripplot(x=employment.Age ,palette=\"Set2\", y = employment.Unemployed , hue=employment.Gender,jitter=True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 307,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 155816 characters]\n",
      "text/plain": [
       "<Figure size 1152x720 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Separate the strips for different hue levels along the categorical axis using \"dodge=True\"\n",
    "plt.figure(figsize=(16,10))\n",
    "sns.stripplot(x=employment.Age ,palette=\"Set2\", y = employment.Unemployed , hue=employment.Gender,jitter=.2, dodge=True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 308,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 243252 characters]\n",
      "text/plain": [
       "<Figure size 1152x720 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(16,10))\n",
    "sns.stripplot(x=employment.Age ,palette=\"Set2\", y = employment.Unemployed , \n",
    "              hue=employment.Gender, marker = \"o\" , size = 30 , alpha = .15)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 309,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 93736 characters]\n",
      "text/plain": [
       "<Figure size 792x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Drawing stripplot on top of a box plot\n",
    "plt.figure(figsize=(11,8))\n",
    "sns.stripplot(x=employment.Age, y = employment.Unemployed , jitter=True , color=\"black\" , size=4)\n",
    "sns.boxplot(x=employment.Age ,palette=\"Set1\", y = employment.Unemployed , color='black')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 483,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 59304 characters]\n",
      "text/plain": [
       "<Figure size 720x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(10,9))\n",
    "sns.set(rc={\"axes.facecolor\":\"#b0deff\",\"axes.grid\":False,\n",
    "            'xtick.labelsize':15,'ytick.labelsize':15,\n",
    "            'axes.labelsize':20,'figure.figsize':(20.0, 9.0)})\n",
    "params = dict(data=exercise ,x = exercise.kind ,y = exercise.pulse ,hue=exercise.diet,dodge=True)\n",
    "sns.stripplot(**params , size=9,jitter=0.35,palette=['#FF8F00','#558B2F'],edgecolor='black',linewidth=1)\n",
    "sns.boxplot(**params ,palette=['#909497','#D0D3D4'],linewidth=4)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 384,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 379832 characters]\n",
      "text/plain": [
       "<Figure size 1152x792 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(16,11))\n",
    "sns.set(rc={\"axes.facecolor\":\"#b0deff\",\"axes.grid\":False,\n",
    "            'xtick.labelsize':15,'ytick.labelsize':15,\n",
    "            'axes.labelsize':20,'figure.figsize':(20.0, 9.0)})\n",
    "params = dict(data=employment ,x = employment.Age ,y = employment.Unemployed ,hue=employment.Gender,dodge=True)\n",
    "sns.stripplot(**params , size=8,jitter=0.35,palette=['#33FF66','#FF6600'],edgecolor='black',linewidth=1)\n",
    "sns.boxplot(**params ,palette=['#BDBDBD','#E0E0E0'],linewidth=6)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 313,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline\n",
    "sns.set_style(\"white\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 314,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 168112 characters]\n",
      "text/plain": [
       "<Figure size 1008x720 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Drawing stripplot on top of a violin plot\n",
    "plt.figure(figsize=(14,10))\n",
    "sns.stripplot(x=employment.Age, y = employment.Unemployed , jitter=True , color=\"black\" , size=4)\n",
    "sns.violinplot(x=employment.Age , y = employment.Unemployed , palette=\"Set1\" , scale=\"count\" , inner=None)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 315,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 792x648 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 136200 characters]\n",
      "text/plain": [
       "<Figure size 1382.4x576 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.catplot(x=\"Age\" , y = \"Unemployed\", col=\"Gender\", kind=\"strip\",palette=\"Set1\" , height=8, aspect=1.2 , \n",
    "            data=employment)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 316,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 792x648 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 112268 characters]\n",
      "text/plain": [
       "<Figure size 1263x576 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.catplot(x=\"parental level of education\" , y = \"math score\", hue= \"test preparation course\",\n",
    "            col=\"lunch\", kind=\"strip\",palette=\"Set2\" , height=8, aspect=1 ,data=stdperf , split = True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Box Plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### The box plot is a standardized way of displaying the distribution of data based on the five number summary: minimum, first quartile, median, third quartile, and maximum."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 840,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline\n",
    "sns.set_style(\"white\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 841,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>sex</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>smoker</th>\n",
       "      <th>region</th>\n",
       "      <th>charges</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "      <td>southwest</td>\n",
       "      <td>16884.92400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>1725.55230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>male</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>4449.46200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>male</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>21984.47061</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>male</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>3866.85520</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     sex     bmi  children smoker     region      charges\n",
       "0   19  female  27.900         0    yes  southwest  16884.92400\n",
       "1   18    male  33.770         1     no  southeast   1725.55230\n",
       "2   28    male  33.000         3     no  southeast   4449.46200\n",
       "3   33    male  22.705         0     no  northwest  21984.47061\n",
       "4   32    male  28.880         0     no  northwest   3866.85520"
      ]
     },
     "execution_count": 841,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insurance.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 842,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1edd712cda0>"
      ]
     },
     "execution_count": 842,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 5704 characters]\n",
      "text/plain": [
       "<Figure size 576x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Simple boxplot\n",
    "plt.figure(figsize=(8,6))\n",
    "sns.boxplot(insurance.bmi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 848,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1edd8b64630>"
      ]
     },
     "execution_count": 848,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 11340 characters]\n",
      "text/plain": [
       "<Figure size 576x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Vertical boxplot\n",
    "sns.set_style(\"darkgrid\")\n",
    "plt.figure(figsize=(8,6))\n",
    "sns.boxplot(x= insurance.smoker , y= insurance.charges )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 849,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1edd8dfe080>"
      ]
     },
     "execution_count": 849,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 11372 characters]\n",
      "text/plain": [
       "<Figure size 576x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Explicit ordering using \"order\" parameter\n",
    "plt.figure(figsize=(8,6))\n",
    "sns.boxplot(x= insurance.smoker , y= insurance.charges , order = ['no' , 'yes'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 850,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ticket</th>\n",
       "      <th>requestor</th>\n",
       "      <th>RequestorSeniority</th>\n",
       "      <th>ITOwner</th>\n",
       "      <th>FiledAgainst</th>\n",
       "      <th>TicketType</th>\n",
       "      <th>Severity</th>\n",
       "      <th>Priority</th>\n",
       "      <th>daysOpen</th>\n",
       "      <th>Satisfaction</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1929</td>\n",
       "      <td>1 - Junior</td>\n",
       "      <td>50</td>\n",
       "      <td>Systems</td>\n",
       "      <td>Issue</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>3</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1587</td>\n",
       "      <td>2 - Regular</td>\n",
       "      <td>15</td>\n",
       "      <td>Software</td>\n",
       "      <td>Request</td>\n",
       "      <td>1 - Minor</td>\n",
       "      <td>1 - Low</td>\n",
       "      <td>5</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>925</td>\n",
       "      <td>2 - Regular</td>\n",
       "      <td>15</td>\n",
       "      <td>Access/Login</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>0</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>413</td>\n",
       "      <td>4 - Management</td>\n",
       "      <td>22</td>\n",
       "      <td>Systems</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>0 - Unassigned</td>\n",
       "      <td>20</td>\n",
       "      <td>0 - Unknown</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>318</td>\n",
       "      <td>1 - Junior</td>\n",
       "      <td>22</td>\n",
       "      <td>Access/Login</td>\n",
       "      <td>Request</td>\n",
       "      <td>2 - Normal</td>\n",
       "      <td>1 - Low</td>\n",
       "      <td>1</td>\n",
       "      <td>1 - Unsatisfied</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ticket  requestor RequestorSeniority  ITOwner  FiledAgainst TicketType  \\\n",
       "0       1       1929         1 - Junior       50       Systems      Issue   \n",
       "1       2       1587        2 - Regular       15      Software    Request   \n",
       "2       3        925        2 - Regular       15  Access/Login    Request   \n",
       "3       4        413     4 - Management       22       Systems    Request   \n",
       "4       5        318         1 - Junior       22  Access/Login    Request   \n",
       "\n",
       "     Severity        Priority  daysOpen     Satisfaction  \n",
       "0  2 - Normal  0 - Unassigned         3  1 - Unsatisfied  \n",
       "1   1 - Minor         1 - Low         5  1 - Unsatisfied  \n",
       "2  2 - Normal  0 - Unassigned         0      0 - Unknown  \n",
       "3  2 - Normal  0 - Unassigned        20      0 - Unknown  \n",
       "4  2 - Normal         1 - Low         1  1 - Unsatisfied  "
      ]
     },
     "execution_count": 850,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "helpdesk.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 851,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 6640 characters]\n",
      "text/plain": [
       "<Figure size 504x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(7,6))\n",
    "sns.boxplot(helpdesk.daysOpen )\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 852,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1edd71db668>"
      ]
     },
     "execution_count": 852,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 14204 characters]\n",
      "text/plain": [
       "<Figure size 576x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(8,6))\n",
    "sns.boxplot(x= helpdesk.FiledAgainst , y= helpdesk.daysOpen )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 853,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1edd57ea208>"
      ]
     },
     "execution_count": 853,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 15804 characters]\n",
      "text/plain": [
       "<Figure size 576x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(8,6))\n",
    "sns.boxplot(x= fish.Species , y= fish.Weight)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 854,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gender</th>\n",
       "      <th>race/ethnicity</th>\n",
       "      <th>parental level of education</th>\n",
       "      <th>lunch</th>\n",
       "      <th>test preparation course</th>\n",
       "      <th>math score</th>\n",
       "      <th>reading score</th>\n",
       "      <th>writing score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>bachelor's degree</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>72</td>\n",
       "      <td>72</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>female</td>\n",
       "      <td>group C</td>\n",
       "      <td>some college</td>\n",
       "      <td>standard</td>\n",
       "      <td>completed</td>\n",
       "      <td>69</td>\n",
       "      <td>90</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>master's degree</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>90</td>\n",
       "      <td>95</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>male</td>\n",
       "      <td>group A</td>\n",
       "      <td>associate's degree</td>\n",
       "      <td>free/reduced</td>\n",
       "      <td>none</td>\n",
       "      <td>47</td>\n",
       "      <td>57</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>male</td>\n",
       "      <td>group C</td>\n",
       "      <td>some college</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>76</td>\n",
       "      <td>78</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>associate's degree</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>71</td>\n",
       "      <td>83</td>\n",
       "      <td>78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>some college</td>\n",
       "      <td>standard</td>\n",
       "      <td>completed</td>\n",
       "      <td>88</td>\n",
       "      <td>95</td>\n",
       "      <td>92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>male</td>\n",
       "      <td>group B</td>\n",
       "      <td>some college</td>\n",
       "      <td>free/reduced</td>\n",
       "      <td>none</td>\n",
       "      <td>40</td>\n",
       "      <td>43</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>male</td>\n",
       "      <td>group D</td>\n",
       "      <td>high school</td>\n",
       "      <td>free/reduced</td>\n",
       "      <td>completed</td>\n",
       "      <td>64</td>\n",
       "      <td>64</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>high school</td>\n",
       "      <td>free/reduced</td>\n",
       "      <td>none</td>\n",
       "      <td>38</td>\n",
       "      <td>60</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   gender race/ethnicity parental level of education         lunch  \\\n",
       "0  female        group B           bachelor's degree      standard   \n",
       "1  female        group C                some college      standard   \n",
       "2  female        group B             master's degree      standard   \n",
       "3    male        group A          associate's degree  free/reduced   \n",
       "4    male        group C                some college      standard   \n",
       "5  female        group B          associate's degree      standard   \n",
       "6  female        group B                some college      standard   \n",
       "7    male        group B                some college  free/reduced   \n",
       "8    male        group D                 high school  free/reduced   \n",
       "9  female        group B                 high school  free/reduced   \n",
       "\n",
       "  test preparation course  math score  reading score  writing score  \n",
       "0                    none          72             72             74  \n",
       "1               completed          69             90             88  \n",
       "2                    none          90             95             93  \n",
       "3                    none          47             57             44  \n",
       "4                    none          76             78             75  \n",
       "5                    none          71             83             78  \n",
       "6               completed          88             95             92  \n",
       "7                    none          40             43             39  \n",
       "8               completed          64             64             67  \n",
       "9                    none          38             60             50  "
      ]
     },
     "execution_count": 854,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stdperf = pd.read_csv(\"studentp.csv\")\n",
    "stdperf.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 855,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 60704 characters]\n",
      "text/plain": [
       "<Figure size 1008x1728 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Adjust width of boxes\n",
    "plt.subplots(figsize = (14,24))\n",
    "plt.subplot(3,1,1)\n",
    "\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] ,  width=.7 )\n",
    "\n",
    "plt.subplot(3,1,2)\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['reading score'] ,  width=.5)\n",
    "\n",
    "plt.subplot(3,1,3)\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['writing score'] ,  width=.25)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 856,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 10676 characters]\n",
      "text/plain": [
       "<Figure size 432x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize = (6,7))\n",
    "sns.boxplot(x= exercise.kind , y= exercise.pulse)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 857,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 13704 characters]\n",
      "text/plain": [
       "<Figure size 432x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\"\n",
    "plt.figure(figsize = (6,7))\n",
    "sns.boxplot(x= exercise.kind , y= exercise.pulse , hue=exercise.diet)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 862,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 32112 characters]\n",
      "text/plain": [
       "<Figure size 1008x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize = (14,8))\n",
    "plt.text(1.5,105, \"Box Plot\", fontsize = 50, color='Black')\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] ,  \n",
    "            width=.7 , hue=stdperf['test preparation course'])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 863,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.set_style(\"white\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 864,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23612 characters]\n",
      "text/plain": [
       "<Figure size 1008x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize = (14,6))\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] , \n",
    "            width=.7 , hue=stdperf['test preparation course'] , palette= 'rainbow')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 865,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23600 characters]\n",
      "text/plain": [
       "<Figure size 1008x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize = (14,6))\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] , \n",
    "            width=.7 , hue=stdperf['test preparation course'] , \n",
    "            palette= {\"none\":'#FFB74D' , \"completed\":'#9CCC65'} )\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 866,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23552 characters]\n",
      "text/plain": [
       "<Figure size 1008x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Remove the top and right axis spines\n",
    "plt.figure(figsize = (14,6))\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] , \n",
    "            width=.7 , hue=stdperf['test preparation course'] , \n",
    "            palette= {\"none\":'#FFB74D' , \"completed\":'#9CCC65'} )\n",
    "sns.despine()\n",
    "# More about sns.despine() here - https://seaborn.pydata.org/tutorial/aesthetics.html\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 867,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23492 characters]\n",
      "text/plain": [
       "<Figure size 1008x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize = (14,6))\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] , \n",
    "            width=.7 , hue=stdperf['test preparation course'] , \n",
    "            palette= {\"none\":'#FFB74D' , \"completed\":'#9CCC65'} )\n",
    "sns.despine(left=True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 807,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23116 characters]\n",
      "text/plain": [
       "<Figure size 1008x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing Linewidth\n",
    "plt.figure(figsize = (14,6))\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] , \n",
    "            width=.7 , hue=stdperf['test preparation course'] , \n",
    "            palette= {\"none\":'#FFB74D' , \"completed\":'#9CCC65'} ,linewidth = 3)\n",
    "sns.despine(left=True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 869,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 31776 characters]\n",
      "text/plain": [
       "<Figure size 1008x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize = (14,6))\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] , \n",
    "            width=.7 , hue=stdperf['test preparation course'] , \n",
    "            palette= {\"none\":'#FFB74D' , \"completed\":'#9CCC65'} ,linewidth = 2)\n",
    "sns.despine(left=True)\n",
    "plt.xticks(rotation=45)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 870,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 48708 characters]\n",
      "text/plain": [
       "<Figure size 1008x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Add a notch to the box\n",
    "plt.figure(figsize = (14,6))\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] , \n",
    "            width=.7 , hue=stdperf['test preparation course'] , \n",
    "            palette= {\"none\":'#FFB74D' , \"completed\":'#9CCC65'} ,linewidth = 2 , notch=True )\n",
    "sns.despine(left=True)\n",
    "plt.xticks(rotation=45)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 871,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 36424 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Change the size of outlier markers\n",
    "plt.figure(figsize = (16,8))\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] , \n",
    "            width=.7 , hue=stdperf['test preparation course'] , \n",
    "            palette= {\"none\":'#FFB74D' , \"completed\":'#9CCC65'} ,linewidth = 2  , fliersize= 15)\n",
    "sns.despine(left=True)\n",
    "plt.xticks(rotation=45)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 872,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 65232 characters]\n",
      "text/plain": [
       "<Figure size 1440x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Change the size of outlier markers\n",
    "sns.set(rc={\"axes.facecolor\":\"#b0deff\",\"axes.grid\":False,\n",
    "            'xtick.labelsize':15,'ytick.labelsize':15,\n",
    "            'axes.labelsize':20,'figure.figsize':(20.0, 9.0)})\n",
    "sns.boxplot(x= stdperf['parental level of education'] , y= stdperf['math score'] , \n",
    "            width=.7 , hue=stdperf['test preparation course'] , \n",
    "            palette= {\"none\":'#FFB74D' , \"completed\":'#9CCC65'} ,linewidth = 2  , fliersize= 15)\n",
    "sns.despine(left=True)\n",
    "plt.xticks(rotation=45)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 873,
   "metadata": {},
   "outputs": [],
   "source": [
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 874,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 365404 characters]\n",
      "text/plain": [
       "<Figure size 1008x792 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(14,11))\n",
    "sns.set(rc={\"axes.grid\":False,\n",
    "            'xtick.labelsize':15,'ytick.labelsize':15,\n",
    "            'axes.labelsize':20,'figure.figsize':(20.0, 9.0)})\n",
    "params = dict(data=employment ,x = employment.Age ,y = employment.Unemployed)\n",
    "sns.stripplot(**params , size=8,jitter=0.35,palette=['#33FF66','#FF6600'],edgecolor='black',linewidth=1 , alpha = 1)\n",
    "sns.boxplot(**params ,palette=['#BDBDBD','#E0E0E0'],linewidth=6)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 875,
   "metadata": {},
   "outputs": [],
   "source": [
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline\n",
    "sns.set_style(\"darkgrid\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 876,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>diet</th>\n",
       "      <th>pulse</th>\n",
       "      <th>time</th>\n",
       "      <th>kind</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>85</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>85</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>low fat</td>\n",
       "      <td>88</td>\n",
       "      <td>30 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>90</td>\n",
       "      <td>1 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>low fat</td>\n",
       "      <td>92</td>\n",
       "      <td>15 min</td>\n",
       "      <td>rest</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id     diet  pulse    time  kind\n",
       "0   1  low fat     85   1 min  rest\n",
       "1   1  low fat     85  15 min  rest\n",
       "2   1  low fat     88  30 min  rest\n",
       "3   2  low fat     90   1 min  rest\n",
       "4   2  low fat     92  15 min  rest"
      ]
     },
     "execution_count": 876,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "exercise.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 877,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 1296x1152 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 14408 characters]\n",
      "text/plain": [
       "<Figure size 720x360 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(18,16))\n",
    "sns.catplot(x=\"kind\", y=\"pulse\",col=\"diet\",data=exercise, kind=\"box\");\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 878,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 159876 characters]\n",
      "text/plain": [
       "<Figure size 1440x1728 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Displaying multiple violin plots using subplot function. \n",
    "fig1 , axes = plt.subplots(nrows=2,ncols=2 , figsize = (20,24))\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_width\" , ax = axes[0,0] ,data=iris , color=\".10\" , size=8,)\n",
    "sns.boxplot(x=\"species\" , y = \"petal_width\" , ax = axes[0,0] ,data=iris )\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_length\" ,ax = axes[0,1] , data=iris  ,  color=\".10\", size=8)\n",
    "sns.boxplot(x=\"species\" , y = \"petal_length\" ,ax = axes[0,1] , data=iris)\n",
    "sns.swarmplot(x=\"species\" , y = \"sepal_width\" , ax = axes[1,0] , data=iris ,  color=\".10\", size=8)\n",
    "sns.boxplot(x=\"species\" , y = \"sepal_width\" , ax = axes[1,0] , data=iris)\n",
    "sns.swarmplot(x=\"species\" , y = \"sepal_length\" , ax = axes[1,1] , data=iris ,  color=\".10\", size=8)\n",
    "sns.boxplot(x=\"species\" , y = \"sepal_length\" , ax = axes[1,1] , data=iris)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 879,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 159572 characters]\n",
      "text/plain": [
       "<Figure size 1440x1728 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig1 , axes = plt.subplots(nrows=2,ncols=2 , figsize = (20,24))\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_width\" , ax = axes[0,0] ,data=iris, size=8,)\n",
    "sns.boxplot(x=\"species\" , y = \"petal_width\" , ax = axes[0,0] ,data=iris ,boxprops={'facecolor':'None'})\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_length\" ,ax = axes[0,1] , data=iris  , size=8)\n",
    "sns.boxplot(x=\"species\" , y = \"petal_length\" ,ax = axes[0,1] , data=iris ,boxprops={'facecolor':'None'})\n",
    "sns.swarmplot(x=\"species\" , y = \"sepal_width\" , ax = axes[1,0] , data=iris ,  size=8)\n",
    "sns.boxplot(x=\"species\" , y = \"sepal_width\" , ax = axes[1,0] , data=iris ,boxprops={'facecolor':'None'})\n",
    "sns.swarmplot(x=\"species\" , y = \"sepal_length\" , ax = axes[1,1] , data=iris, size=8)\n",
    "sns.boxplot(x=\"species\" , y = \"sepal_length\" , ax = axes[1,1] , data=iris ,boxprops={'facecolor':'None'})\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 880,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 154056 characters]\n",
      "text/plain": [
       "<Figure size 1440x1728 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig1 , axes = plt.subplots(nrows=2,ncols=2 , figsize = (20,24))\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_width\" , ax = axes[0,0] ,data=iris, size=8)\n",
    "sns.boxplot(x=\"species\" , y = \"petal_width\" , ax = axes[0,0] ,data=iris , showfliers=False,whiskerprops={'linewidth':0},showcaps=False,boxprops={'facecolor':'None' , 'linewidth' : 3 })\n",
    "sns.swarmplot(x=\"species\" , y = \"petal_length\" ,ax = axes[0,1] , data=iris, size=8)\n",
    "sns.boxplot(x=\"species\" , y = \"petal_length\" ,ax = axes[0,1] , data=iris , showfliers=False,whiskerprops={'linewidth':0},showcaps=False,boxprops={'facecolor':'None' , 'linewidth' : 3})\n",
    "sns.swarmplot(x=\"species\" , y = \"sepal_width\" , ax = axes[1,0] , data=iris, size=8)\n",
    "sns.boxplot(x=\"species\" , y = \"sepal_width\" , ax = axes[1,0] , data=iris , showfliers=False,whiskerprops={'linewidth':0},showcaps=False,boxprops={'facecolor':'None' , 'linewidth' : 3})\n",
    "sns.swarmplot(x=\"species\" , y = \"sepal_length\" , ax = axes[1,1] , data=iris , size=8)\n",
    "sns.boxplot(x=\"species\" , y = \"sepal_length\" , ax = axes[1,1] , data=iris , showfliers=False,whiskerprops={'linewidth':0},showcaps=False,boxprops={'facecolor':'None' , 'linewidth' : 3})\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Boxen Plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### The Boxen Plot shows a large number of quantiles.By plotting more quantiles, it provides more information about the shape of the distribution, particularly in the tails."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 881,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline\n",
    "sns.set_style(\"darkgrid\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 882,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 8836 characters]\n",
      "text/plain": [
       "<Figure size 360x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Simple Boxen Plot\n",
    "plt.figure(figsize=(5,7))\n",
    "sns.boxenplot(y=employment.Unemployed)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 883,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 13284 characters]\n",
      "text/plain": [
       "<Figure size 504x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(7,9))\n",
    "sns.boxenplot(x=employment.Gender , y = employment.Unemployed ,palette=\"Set1\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 884,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23972 characters]\n",
      "text/plain": [
       "<Figure size 720x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Drawing a vertical boxenplot grouped by a categorical variable\n",
    "plt.figure(figsize=(10,9))\n",
    "sns.boxenplot(x=employment.Age , y = employment.Unemployed ,palette=\"Set1\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 886,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23772 characters]\n",
      "text/plain": [
       "<Figure size 792x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Using spring palette\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.boxenplot(x=employment.Age , y = employment.Unemployed,palette=\"spring\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 888,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 28908 characters]\n",
      "text/plain": [
       "<Figure size 792x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.set(rc={\"axes.facecolor\":\"#616161\" , \"axes.grid\" : False})\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.boxenplot(x=employment.Age , y = employment.Unemployed,palette=\"Set1\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 939,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 34184 characters]\n",
      "text/plain": [
       "<Figure size 792x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.set(rc={\"axes.facecolor\":\"#a1c45a\" , \"axes.grid\" : False})\n",
    "plt.figure(figsize=(11,9))\n",
    "plt.gcf().text(.51, .84, \"Box Plot\", fontsize = 40, color='Black' ,ha='center', va='center')\n",
    "sns.boxenplot(x=employment.Age , y = employment.Unemployed,palette=\"Set1\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 940,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 30740 characters]\n",
      "text/plain": [
       "<Figure size 720x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Horizontal Boxen plot\n",
    "sns.set_style(\"darkgrid\")\n",
    "plt.figure(figsize=(10,9))\n",
    "sns.boxenplot(x = employment.Unemployed ,y=employment.Age ,palette=\"Set1\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 801,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 36024 characters]\n",
      "text/plain": [
       "<Figure size 792x648 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\" (Nested grouping by two categorical variables)\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.boxenplot(x=employment.Age , y = employment.Unemployed, hue=employment.Gender, palette=\"Set2\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 802,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 792x648 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 41220 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.catplot(x=\"Age\" , y = \"Unemployed\", col=\"Gender\", kind=\"boxen\",palette=\"Set2\" , height=8, aspect=1 ,data=employment)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 803,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gender</th>\n",
       "      <th>race/ethnicity</th>\n",
       "      <th>parental level of education</th>\n",
       "      <th>lunch</th>\n",
       "      <th>test preparation course</th>\n",
       "      <th>math score</th>\n",
       "      <th>reading score</th>\n",
       "      <th>writing score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>bachelor's degree</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>72</td>\n",
       "      <td>72</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>female</td>\n",
       "      <td>group C</td>\n",
       "      <td>some college</td>\n",
       "      <td>standard</td>\n",
       "      <td>completed</td>\n",
       "      <td>69</td>\n",
       "      <td>90</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>female</td>\n",
       "      <td>group B</td>\n",
       "      <td>master's degree</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>90</td>\n",
       "      <td>95</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>male</td>\n",
       "      <td>group A</td>\n",
       "      <td>associate's degree</td>\n",
       "      <td>free/reduced</td>\n",
       "      <td>none</td>\n",
       "      <td>47</td>\n",
       "      <td>57</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>male</td>\n",
       "      <td>group C</td>\n",
       "      <td>some college</td>\n",
       "      <td>standard</td>\n",
       "      <td>none</td>\n",
       "      <td>76</td>\n",
       "      <td>78</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   gender race/ethnicity parental level of education         lunch  \\\n",
       "0  female        group B           bachelor's degree      standard   \n",
       "1  female        group C                some college      standard   \n",
       "2  female        group B             master's degree      standard   \n",
       "3    male        group A          associate's degree  free/reduced   \n",
       "4    male        group C                some college      standard   \n",
       "\n",
       "  test preparation course  math score  reading score  writing score  \n",
       "0                    none          72             72             74  \n",
       "1               completed          69             90             88  \n",
       "2                    none          90             95             93  \n",
       "3                    none          47             57             44  \n",
       "4                    none          76             78             75  "
      ]
     },
     "execution_count": 803,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stdperf.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 804,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 792x648 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 49276 characters]\n",
      "text/plain": [
       "<Figure size 1265.05x576 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variable using \"col\" parameter\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.catplot(x=\"parental level of education\" , y = \"math score\", hue= \"test preparation course\",\n",
    "            col=\"lunch\", kind=\"boxen\",palette=\"Set2\" , height=8, aspect=1 ,data=stdperf)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Pair Plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Pair Plot is used for plotting pairwise relationships in a dataset."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Species</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Length1</th>\n",
       "      <th>Length2</th>\n",
       "      <th>Length3</th>\n",
       "      <th>Height</th>\n",
       "      <th>Width</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Bream</td>\n",
       "      <td>242.0</td>\n",
       "      <td>23.2</td>\n",
       "      <td>25.4</td>\n",
       "      <td>30.0</td>\n",
       "      <td>11.5200</td>\n",
       "      <td>4.0200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Bream</td>\n",
       "      <td>290.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>26.3</td>\n",
       "      <td>31.2</td>\n",
       "      <td>12.4800</td>\n",
       "      <td>4.3056</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Bream</td>\n",
       "      <td>340.0</td>\n",
       "      <td>23.9</td>\n",
       "      <td>26.5</td>\n",
       "      <td>31.1</td>\n",
       "      <td>12.3778</td>\n",
       "      <td>4.6961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Bream</td>\n",
       "      <td>363.0</td>\n",
       "      <td>26.3</td>\n",
       "      <td>29.0</td>\n",
       "      <td>33.5</td>\n",
       "      <td>12.7300</td>\n",
       "      <td>4.4555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Bream</td>\n",
       "      <td>430.0</td>\n",
       "      <td>26.5</td>\n",
       "      <td>29.0</td>\n",
       "      <td>34.0</td>\n",
       "      <td>12.4440</td>\n",
       "      <td>5.1340</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Species  Weight  Length1  Length2  Length3   Height   Width\n",
       "0   Bream   242.0     23.2     25.4     30.0  11.5200  4.0200\n",
       "1   Bream   290.0     24.0     26.3     31.2  12.4800  4.3056\n",
       "2   Bream   340.0     23.9     26.5     31.1  12.3778  4.6961\n",
       "3   Bream   363.0     26.3     29.0     33.5  12.7300  4.4555\n",
       "4   Bream   430.0     26.5     29.0     34.0  12.4440  5.1340"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fish.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Species</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Length1</th>\n",
       "      <th>Length2</th>\n",
       "      <th>Length3</th>\n",
       "      <th>Height</th>\n",
       "      <th>Width</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Bream</td>\n",
       "      <td>242.0</td>\n",
       "      <td>23.2</td>\n",
       "      <td>25.4</td>\n",
       "      <td>30.0</td>\n",
       "      <td>11.5200</td>\n",
       "      <td>4.0200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Bream</td>\n",
       "      <td>290.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>26.3</td>\n",
       "      <td>31.2</td>\n",
       "      <td>12.4800</td>\n",
       "      <td>4.3056</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Bream</td>\n",
       "      <td>340.0</td>\n",
       "      <td>23.9</td>\n",
       "      <td>26.5</td>\n",
       "      <td>31.1</td>\n",
       "      <td>12.3778</td>\n",
       "      <td>4.6961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Bream</td>\n",
       "      <td>363.0</td>\n",
       "      <td>26.3</td>\n",
       "      <td>29.0</td>\n",
       "      <td>33.5</td>\n",
       "      <td>12.7300</td>\n",
       "      <td>4.4555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Bream</td>\n",
       "      <td>430.0</td>\n",
       "      <td>26.5</td>\n",
       "      <td>29.0</td>\n",
       "      <td>34.0</td>\n",
       "      <td>12.4440</td>\n",
       "      <td>5.1340</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Species  Weight  Length1  Length2  Length3   Height   Width\n",
       "0   Bream   242.0     23.2     25.4     30.0  11.5200  4.0200\n",
       "1   Bream   290.0     24.0     26.3     31.2  12.4800  4.3056\n",
       "2   Bream   340.0     23.9     26.5     31.1  12.3778  4.6961\n",
       "3   Bream   363.0     26.3     29.0     33.5  12.7300  4.4555\n",
       "4   Bream   430.0     26.5     29.0     34.0  12.4440  5.1340"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fish1 = fish[fish['Species'].isin(['Bream', 'Perch', 'Pike'])]\n",
    "fish1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 792x648 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 173908 characters]\n",
      "text/plain": [
       "<Figure size 1080x1080 with 42 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Draw scatterplots for joint relationships and histograms for univariate distributions\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.pairplot(fish1,hue = 'Species')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 792x648 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 231976 characters]\n",
      "text/plain": [
       "<Figure size 1148.88x1080 with 42 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\"\n",
    "plt.figure(figsize=(11,9))\n",
    "sns.pairplot(fish1,hue = 'Species')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 184072 characters]\n",
      "text/plain": [
       "<Figure size 932.875x864 with 42 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing palettes\n",
    "sns.pairplot(fish1,hue = 'Species',palette=\"husl\",size=2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 155620 characters]\n",
      "text/plain": [
       "<Figure size 932.875x864 with 20 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plot a subset of variables\n",
    "sns.pairplot(fish1,hue = 'Species',vars=[\"Length1\", \"Weight\" , \"Height\" , \"Width\"] , height=3, aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 160584 characters]\n",
      "text/plain": [
       "<Figure size 932.875x864 with 20 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Use different markers for each level of the hue variable\n",
    "sns.pairplot(fish1,hue = 'Species',vars=[\"Length1\", \"Weight\" , \"Height\" , \"Width\"] , \n",
    "             markers= ['o' , 'D' , '<'] , height=3, aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 159000 characters]\n",
      "text/plain": [
       "<Figure size 1148.88x1080 with 12 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.pairplot(fish1,hue = 'Species',vars=[\"Weight\" , \"Height\" , \"Width\"] , \n",
    "             markers= ['o' , 'D' , '<'] , height=5, aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 97216 characters]\n",
      "text/plain": [
       "<Figure size 1148.88x1080 with 9 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.pairplot(fish1,hue = 'Species',x_vars=[\"Weight\" , \"Height\" , \"Width\"] , y_vars=[\"Length1\" , \"Length2\" , \"Length3\"],\n",
    "             markers= ['o' , 'D' , '<'] , height=5, aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 236116 characters]\n",
      "text/plain": [
       "<Figure size 1148.88x1080 with 12 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Fit linear regression models to the scatter plots\n",
    "sns.pairplot(fish1,hue = 'Species',vars=[\"Weight\" , \"Height\" , \"Width\"] , kind=\"reg\",\n",
    "              height=5, aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 205236 characters]\n",
      "text/plain": [
       "<Figure size 1148.88x1080 with 12 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing size of circles in scatter plots using -> plot_kws=dict(s=140)\n",
    "sns.pairplot(fish1,hue = 'Species',vars=[\"Weight\" , \"Height\" , \"Width\"] , plot_kws=dict(s=140, linewidth=1),\n",
    "             height=5, aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 233564 characters]\n",
      "text/plain": [
       "<Figure size 1148.88x1080 with 12 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.pairplot(fish1,hue = 'Species',vars=[\"Weight\" , \"Height\" , \"Width\"] , plot_kws=dict(s=140, linewidth=1,alpha= .6),\n",
    "             height=5, aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 115848 characters]\n",
      "text/plain": [
       "<Figure size 788.875x720 with 6 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.pairplot(fish1,hue = 'Species',x_vars=[\"Weight\" , \"Height\"] ,\n",
    "             y_vars=[\"Weight\" , \"Height\"] ,plot_kws=dict(s=140, linewidth=1,alpha= .6),\n",
    "             height=5, aspect=1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Pair Grid"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Pair Grid is a Subplot grid for plotting pairwise relationships in a dataset. Different axes-level plotting functions can be used to draw bivariate plots in the upper and lower triangles, and the the marginal distribution of each variable can be shown on the diagonal."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 412,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 115584 characters]\n",
      "text/plain": [
       "<Figure size 1080x1080 with 36 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#scatterplot for each pairwise relationship\n",
    "g = sns.PairGrid(fish1)\n",
    "g = g.map(plt.scatter)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 413,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 107832 characters]\n",
      "text/plain": [
       "<Figure size 1080x1080 with 42 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram on the diagonal \n",
    "g = sns.PairGrid(fish1)\n",
    "g = g.map_offdiag(plt.scatter)\n",
    "g = g.map_diag(plt.hist)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 414,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 135716 characters]\n",
      "text/plain": [
       "<Figure size 1148.88x1080 with 42 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\"\n",
    "g = sns.PairGrid(fish1 , hue='Species')\n",
    "g = g.map_offdiag(plt.scatter)\n",
    "g = g.map_diag(plt.hist)\n",
    "g = g.add_legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 415,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 133684 characters]\n",
      "text/plain": [
       "<Figure size 1148.88x1080 with 42 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "g = sns.PairGrid(fish1 , hue='Species', palette=\"husl\")\n",
    "g = g.map_offdiag(plt.scatter)\n",
    "g = g.map_diag(plt.hist)\n",
    "g = g.add_legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 416,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 137332 characters]\n",
      "text/plain": [
       "<Figure size 1148.88x1080 with 42 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing histogram styling\n",
    "g = sns.PairGrid(fish1 , hue='Species')\n",
    "g = g.map_offdiag(plt.scatter)\n",
    "g = g.map_diag(plt.hist , histtype=\"step\", linewidth=2)\n",
    "g = g.add_legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 417,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 128528 characters]\n",
      "text/plain": [
       "<Figure size 1148.88x1080 with 12 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plot a subset of variables\n",
    "g = sns.PairGrid(fish1 , hue='Species' ,vars=[\"Weight\" , \"Height\" , \"Width\"],height=5, aspect=1)\n",
    "g = g.map_offdiag(plt.scatter , edgecolor=\"w\", s=130)\n",
    "g = g.map_diag(plt.hist , edgecolor ='w', linewidth=2)\n",
    "g = g.add_legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 418,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 65084 characters]\n",
      "text/plain": [
       "<Figure size 932.875x864 with 6 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plot a subset of variables\n",
    "g = sns.PairGrid(fish1 , hue='Species' ,x_vars=[\"Weight\" , \"Height\"],y_vars=[\"Weight\" , \"Height\"],\n",
    "                 height=6, aspect=1)\n",
    "g = g.map_offdiag(plt.scatter , edgecolor=\"w\", s=130)\n",
    "g = g.map_diag(plt.hist , edgecolor ='w', linewidth=2)\n",
    "g = g.add_legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 419,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 77660 characters]\n",
      "text/plain": [
       "<Figure size 932.875x864 with 4 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "g = sns.PairGrid(fish1 , hue='Species' ,x_vars=[\"Weight\" , \"Height\"],y_vars=[\"Weight\" , \"Height\"],\n",
    "                 height=6, aspect=1 , hue_kws={\"marker\": [\"o\", \"^\", \"v\"]})\n",
    "g = g.map(plt.scatter , edgecolor=\"w\", s=130)\n",
    "g = g.add_legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 420,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 256656 characters]\n",
      "text/plain": [
       "<Figure size 1088x1080 with 12 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Using different plots on the upper and lower triangles\n",
    "g = sns.PairGrid(fish1 ,vars=[\"Length1\" , \"Height\" , \"Width\"],height=5, aspect=1)\n",
    "g = g.map_upper(sns.scatterplot , edgecolor=\"w\", s=130)\n",
    "g = g.map_lower(sns.kdeplot)\n",
    "g = g.map_diag(sns.kdeplot , lw= 2)\n",
    "g = g.add_legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Regression Plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Regression plot is used to plot data and a linear regression model fit."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 421,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 422,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Species</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Length1</th>\n",
       "      <th>Length2</th>\n",
       "      <th>Length3</th>\n",
       "      <th>Height</th>\n",
       "      <th>Width</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Bream</td>\n",
       "      <td>242.0</td>\n",
       "      <td>23.2</td>\n",
       "      <td>25.4</td>\n",
       "      <td>30.0</td>\n",
       "      <td>11.5200</td>\n",
       "      <td>4.0200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Bream</td>\n",
       "      <td>290.0</td>\n",
       "      <td>24.0</td>\n",
       "      <td>26.3</td>\n",
       "      <td>31.2</td>\n",
       "      <td>12.4800</td>\n",
       "      <td>4.3056</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Bream</td>\n",
       "      <td>340.0</td>\n",
       "      <td>23.9</td>\n",
       "      <td>26.5</td>\n",
       "      <td>31.1</td>\n",
       "      <td>12.3778</td>\n",
       "      <td>4.6961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Bream</td>\n",
       "      <td>363.0</td>\n",
       "      <td>26.3</td>\n",
       "      <td>29.0</td>\n",
       "      <td>33.5</td>\n",
       "      <td>12.7300</td>\n",
       "      <td>4.4555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Bream</td>\n",
       "      <td>430.0</td>\n",
       "      <td>26.5</td>\n",
       "      <td>29.0</td>\n",
       "      <td>34.0</td>\n",
       "      <td>12.4440</td>\n",
       "      <td>5.1340</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Species  Weight  Length1  Length2  Length3   Height   Width\n",
       "0   Bream   242.0     23.2     25.4     30.0  11.5200  4.0200\n",
       "1   Bream   290.0     24.0     26.3     31.2  12.4800  4.3056\n",
       "2   Bream   340.0     23.9     26.5     31.1  12.3778  4.6961\n",
       "3   Bream   363.0     26.3     29.0     33.5  12.7300  4.4555\n",
       "4   Bream   430.0     26.5     29.0     34.0  12.4440  5.1340"
      ]
     },
     "execution_count": 422,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fish1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 423,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 28352 characters]\n",
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plot the relationship between two variables\n",
    "plt.figure(figsize=(7,7))\n",
    "sns.regplot(x=fish1.Weight , y=fish1.Height)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 424,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 31028 characters]\n",
      "text/plain": [
       "<Figure size 648x648 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plot the relationship between two variables and use a different color\n",
    "plt.figure(figsize=(9,9))\n",
    "sns.regplot(x=fish1.Weight , y=fish1.Height , color='#FF6600')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 425,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 29764 characters]\n",
      "text/plain": [
       "<Figure size 648x648 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(9,9))\n",
    "sns.regplot(x=fish1.Weight , y=fish1.Height , color='#FF6600' , marker='>')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 426,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 32560 characters]\n",
      "text/plain": [
       "<Figure size 648x648 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Use 50% Confidnce interval\n",
    "plt.figure(figsize=(9,9))\n",
    "sns.regplot(x=fish1.Weight , y=fish1.Height , color='#FF6600' , ci=50 , truncate=False)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 427,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 28280 characters]\n",
      "text/plain": [
       "<Figure size 648x648 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Fit the regression model using log(x)\n",
    "plt.figure(figsize=(9,9))\n",
    "sns.regplot(x=fish1.Weight , y=fish1.Height , color='#FF6600' , logx=True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 428,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 29684 characters]\n",
      "text/plain": [
       "<Figure size 648x648 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Change the color and width of regression line -> line_kws={\"color\":\"#FF5722\",\"lw\":3}\n",
    "plt.figure(figsize=(9,9))\n",
    "sns.regplot(x=fish1.Weight , y=fish1.Height , logx=True , line_kws={\"color\":\"#FF5722\",\"alpha\":0.8,\"lw\":3})\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 429,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 105276 characters]\n",
      "text/plain": [
       "<Figure size 744.45x576 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Fit a regression model for a categorical variable\n",
    "sns.lmplot(x=\"bmi\" , y=\"charges\" , hue=\"smoker\" , data=insurance , height=8,aspect=1.2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 430,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 154320 characters]\n",
      "text/plain": [
       "<Figure size 744.45x576 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.lmplot(x=\"bmi\" , y=\"charges\" , hue=\"smoker\" , data=insurance , height=8,aspect=1.2 , \n",
    "           scatter_kws ={'s':90 , 'alpha' : .4} ,  palette=[\"#FF3333\" ,\"#00CC00\"])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 431,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>sex</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>smoker</th>\n",
       "      <th>region</th>\n",
       "      <th>charges</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "      <td>southwest</td>\n",
       "      <td>16884.92400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>1725.55230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>male</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>4449.46200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>male</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>21984.47061</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>male</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>3866.85520</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     sex     bmi  children smoker     region      charges\n",
       "0   19  female  27.900         0    yes  southwest  16884.92400\n",
       "1   18    male  33.770         1     no  southeast   1725.55230\n",
       "2   28    male  33.000         3     no  southeast   4449.46200\n",
       "3   33    male  22.705         0     no  northwest  21984.47061\n",
       "4   32    male  28.880         0     no  northwest   3866.85520"
      ]
     },
     "execution_count": 431,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insurance.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 432,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x22eade47048>"
      ]
     },
     "execution_count": 432,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 96936 characters]\n",
      "text/plain": [
       "<Figure size 917.25x432 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plot the levels of the third variable across different columns\n",
    "sns.lmplot(x=\"bmi\", y=\"charges\", hue=\"smoker\", col=\"sex\", data=insurance ,height=6,aspect=1 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 433,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x22eadd524e0>"
      ]
     },
     "execution_count": 433,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 152928 characters]\n",
      "text/plain": [
       "<Figure size 1061.25x1008 with 4 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\" Facet along the columns to show a categorical variable using \"col\" parameter and \n",
    "Limiting the number of columns using \"col_wrap\" \"\"\"\n",
    "\n",
    "sns.lmplot(x=\"bmi\", y=\"charges\", hue=\"smoker\", col=\"region\", data=insurance ,height=7,aspect=1,col_wrap = 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 434,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x22ebb75b320>"
      ]
     },
     "execution_count": 434,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 90300 characters]\n",
      "text/plain": [
       "<Figure size 1152x576 with 8 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns and rows to show a categorical variables using \"col\" and \"row\" parameter\n",
    "sns.lmplot(x=\"bmi\", y=\"charges\", row=\"smoker\", col=\"region\", data=insurance ,height=4,aspect=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Heat Map"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A heat map is a data visualization technique that shows magnitude of a phenomenon as color in two dimensions. The variation in color may be by hue or intensity, giving obvious visual cues to the reader about how the phenomenon is clustered or varies over space."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 435,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Germany</th>\n",
       "      <th>France</th>\n",
       "      <th>Mexico</th>\n",
       "      <th>Bangladesh</th>\n",
       "      <th>Brazil</th>\n",
       "      <th>Israel</th>\n",
       "      <th>Egypt</th>\n",
       "      <th>Colombia</th>\n",
       "      <th>Iraq</th>\n",
       "      <th>Jamaica</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2004</th>\n",
       "      <td>2020</td>\n",
       "      <td>4391</td>\n",
       "      <td>2259</td>\n",
       "      <td>2660</td>\n",
       "      <td>917</td>\n",
       "      <td>2788</td>\n",
       "      <td>2393</td>\n",
       "      <td>4566</td>\n",
       "      <td>1796</td>\n",
       "      <td>2237</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2005</th>\n",
       "      <td>2226</td>\n",
       "      <td>4429</td>\n",
       "      <td>2837</td>\n",
       "      <td>4171</td>\n",
       "      <td>969</td>\n",
       "      <td>2446</td>\n",
       "      <td>2496</td>\n",
       "      <td>6424</td>\n",
       "      <td>2226</td>\n",
       "      <td>1945</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006</th>\n",
       "      <td>2767</td>\n",
       "      <td>4002</td>\n",
       "      <td>2844</td>\n",
       "      <td>4014</td>\n",
       "      <td>1181</td>\n",
       "      <td>2625</td>\n",
       "      <td>2190</td>\n",
       "      <td>6535</td>\n",
       "      <td>1788</td>\n",
       "      <td>1722</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007</th>\n",
       "      <td>2449</td>\n",
       "      <td>4290</td>\n",
       "      <td>3239</td>\n",
       "      <td>2897</td>\n",
       "      <td>1746</td>\n",
       "      <td>2401</td>\n",
       "      <td>2356</td>\n",
       "      <td>5357</td>\n",
       "      <td>2406</td>\n",
       "      <td>2141</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008</th>\n",
       "      <td>3833</td>\n",
       "      <td>4532</td>\n",
       "      <td>2856</td>\n",
       "      <td>2939</td>\n",
       "      <td>2138</td>\n",
       "      <td>2562</td>\n",
       "      <td>3347</td>\n",
       "      <td>5452</td>\n",
       "      <td>3543</td>\n",
       "      <td>2334</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Germany  France  Mexico  Bangladesh  Brazil  Israel  Egypt  Colombia  \\\n",
       "2004     2020    4391    2259        2660     917    2788   2393      4566   \n",
       "2005     2226    4429    2837        4171     969    2446   2496      6424   \n",
       "2006     2767    4002    2844        4014    1181    2625   2190      6535   \n",
       "2007     2449    4290    3239        2897    1746    2401   2356      5357   \n",
       "2008     3833    4532    2856        2939    2138    2562   3347      5452   \n",
       "\n",
       "      Iraq  Jamaica  \n",
       "2004  1796     2237  \n",
       "2005  2226     1945  \n",
       "2006  1788     1722  \n",
       "2007  2406     2141  \n",
       "2008  3543     2334  "
      ]
     },
     "execution_count": 435,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "canada1 = canada.loc['2004': , ['Germany' , 'France' , 'Mexico' , 'Bangladesh' ,'Brazil','Israel' , 'Egypt' , 'Colombia' , 'Iraq','Jamaica']]\n",
    "canada1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 436,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 20428 characters]\n",
      "text/plain": [
       "<Figure size 1152x648 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(16,9))\n",
    "ax = sns.heatmap(canada1)\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 437,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 19984 characters]\n",
      "text/plain": [
       "<Figure size 1152x648 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing the limits of the colormap\n",
    "plt.figure(figsize=(16,9))\n",
    "ax = sns.heatmap(canada1,vmin=0, vmax=8000)\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 438,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 20512 characters]\n",
      "text/plain": [
       "<Figure size 1152x648 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Plot a heatmap for data centered on 4000 with a diverging colormap\n",
    "plt.figure(figsize=(16,9))\n",
    "ax = sns.heatmap(canada1,center=4000)\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 439,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 19980 characters]\n",
      "text/plain": [
       "<Figure size 1152x648 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing cmap \n",
    "plt.figure(figsize=(16,9))\n",
    "ax = sns.heatmap(canada1,vmin=0, vmax=8000,cmap=\"YlGnBu\")\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 440,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 19984 characters]\n",
      "text/plain": [
       "<Figure size 1152x648 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(16,9))\n",
    "ax = sns.heatmap(canada1,vmin=0, vmax=8000,cmap=\"coolwarm\")\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 441,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 20824 characters]\n",
      "text/plain": [
       "<Figure size 1152x648 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Add lines between each cell\n",
    "plt.figure(figsize=(16,9))\n",
    "ax = sns.heatmap(canada1,vmin=0, vmax=8000,linewidths=.1)\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 442,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 88144 characters]\n",
      "text/plain": [
       "<Figure size 1152x648 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Annotate each cell with the numeric value using integer formatting\n",
    "plt.figure(figsize=(16,9))\n",
    "ax = sns.heatmap(canada1,vmin=0, vmax=8000,annot=True, fmt=\"d\")\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 443,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 124008 characters]\n",
      "text/plain": [
       "<Figure size 1152x648 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Annotate each cell with the numeric value using decimal formatting\n",
    "plt.figure(figsize=(16,9))\n",
    "ax = sns.heatmap(canada1,vmin=0, vmax=8000,cmap=\"YlGnBu\", annot=True ,fmt=\".2f\")\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 444,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 158460 characters]\n",
      "text/plain": [
       "<Figure size 1440x792 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,11))\n",
    "ax = sns.heatmap(canada1,vmin=0, vmax=8000,cmap=\"YlGnBu\", linewidths=.5, annot=True ,annot_kws={'size':14} ,fmt=\".1f\")\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 445,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 154808 characters]\n",
      "text/plain": [
       "<Figure size 1440x792 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Turn off the colorbar -> cbar=False\n",
    "plt.figure(figsize=(20,11))\n",
    "ax = sns.heatmap(canada1,vmin=0, vmax=8000,cmap=\"YlGnBu\", linewidths=.5, \n",
    "                 annot=True ,annot_kws={'size':14} ,fmt=\".1f\" , cbar=False)\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 446,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 149008 characters]\n",
      "text/plain": [
       "<Figure size 1440x792 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Force the aspect ratio of the blocks to be equal using \"square\" parameter\n",
    "plt.figure(figsize=(20,11))\n",
    "ax = sns.heatmap(canada1,vmin=0, vmax=8000,cmap=\"YlGnBu\", linewidths=.5, \n",
    "                 annot=True ,annot_kws={'size':14} ,fmt=\".1f\" , cbar=False ,square = True)\n",
    "plt.yticks(rotation=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 447,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.set(rc={'xtick.labelsize':17,'ytick.labelsize':17,'axes.labelsize':20})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 448,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 190520 characters]\n",
      "text/plain": [
       "<Figure size 1440x864 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(20,12))\n",
    "plt.rcParams['figure.facecolor'] = \"#a1c45a\"\n",
    "plt.rcParams['axes.facecolor'] = \"#a1c45a\"\n",
    "plt.rcParams[ 'axes.labelsize'] = 20\n",
    "plt.rcParams['xtick.labelsize'] = 15\n",
    "plt.rcParams['ytick.labelsize'] = 15\n",
    "\n",
    "ax = sns.heatmap(canada1,vmin=0, vmax=8000,cmap=\"YlGnBu\", linewidths=.5,annot=True ,annot_kws={'size':14} ,fmt=\".1f\")\n",
    "plt.yticks(rotation=0)\n",
    "plt.text(4,-.2, \"Heat Map\", fontsize = 50, color='Black')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Facet Grid\n",
    "\n",
    "##### Multi-plot grid for plotting. A FacetGrid can be drawn with up to three dimensions − row, col, and hue."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 477,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "plt.rcParams[ 'axes.labelsize'] = 10\n",
    "plt.rcParams['xtick.labelsize'] = 10\n",
    "plt.rcParams['ytick.labelsize'] = 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 478,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>sex</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>smoker</th>\n",
       "      <th>region</th>\n",
       "      <th>charges</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "      <td>southwest</td>\n",
       "      <td>16884.92400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>1725.55230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>male</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>4449.46200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>male</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>21984.47061</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>male</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>3866.85520</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     sex     bmi  children smoker     region      charges\n",
       "0   19  female  27.900         0    yes  southwest  16884.92400\n",
       "1   18    male  33.770         1     no  southeast   1725.55230\n",
       "2   28    male  33.000         3     no  southeast   4449.46200\n",
       "3   33    male  22.705         0     no  northwest  21984.47061\n",
       "4   32    male  28.880         0     no  northwest   3866.85520"
      ]
     },
     "execution_count": 478,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insurance.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 479,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 13740 characters]\n",
      "text/plain": [
       "<Figure size 600x300 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns to show a categorical variables using \"col\" parameter (univariate plot on each facet)\n",
    "g = sns.FacetGrid(insurance, col=\"sex\")\n",
    "g = g.map(plt.hist, \"bmi\", edgecolor ='w', linewidth=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 480,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 59292 characters]\n",
      "text/plain": [
       "<Figure size 800x1600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Facet along the columns and rows to show a categorical variables using \"col\" and \"row\" parameter\n",
    "g = sns.FacetGrid(insurance, col=\"sex\" , row = \"region\" , height=4, aspect=1)\n",
    "g = g.map(plt.hist, \"bmi\",edgecolor ='w', linewidth=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 484,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 38756 characters]\n",
      "text/plain": [
       "<Figure size 1200x600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "g = sns.FacetGrid(insurance, col=\"region\" , row = \"sex\" , height=3, aspect=1)\n",
    "g = g.map(plt.hist, \"bmi\",edgecolor ='w', linewidth=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 482,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 38744 characters]\n",
      "text/plain": [
       "<Figure size 1200x600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing color of bars\n",
    "g = sns.FacetGrid(insurance, col=\"region\" , row = \"sex\" , height=3, aspect=1)\n",
    "g = g.map(plt.hist, \"bmi\" , color = '#F39C12',edgecolor ='w', linewidth=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 485,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 114872 characters]\n",
      "text/plain": [
       "<Figure size 1200x600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Bivariate function on each facet\n",
    "g = sns.FacetGrid(insurance, col=\"region\" , row = \"sex\" , height=3, aspect=1)\n",
    "g = g.map(plt.scatter, \"bmi\" , \"charges\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 490,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 150984 characters]\n",
      "text/plain": [
       "<Figure size 1200x600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing size of dots -> s = 80\n",
    "g = sns.FacetGrid(insurance, col=\"region\" , row = \"sex\" , height=3, aspect=1)\n",
    "g = g.map(plt.scatter, \"bmi\" , \"charges\" , color = '#FF6600',edgecolor=\"w\", s=80)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 492,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 151024 characters]\n",
      "text/plain": [
       "<Figure size 1200x600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Show groups with different colors using \"hue\"\n",
    "g = sns.FacetGrid(insurance, col=\"region\" , row = \"sex\" , hue=\"smoker\" ,height=3, aspect=1)\n",
    "g = g.map(plt.scatter, \"bmi\" , \"charges\" , edgecolor=\"w\", s=70)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 493,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x22ebb142358>"
      ]
     },
     "execution_count": 493,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 151988 characters]\n",
      "text/plain": [
       "<Figure size 1153.88x600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Showing legend -> g.add_legend()\n",
    "g = sns.FacetGrid(insurance, col=\"region\" , row = \"sex\" , hue=\"smoker\" ,height=3, aspect=.9)\n",
    "g = g.map(plt.scatter, \"bmi\" , \"charges\",edgecolor=\"w\", s=70)\n",
    "g.add_legend()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 495,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 159456 characters]\n",
      "text/plain": [
       "<Figure size 1273.88x600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Use a custom palette\n",
    "pal1 = dict(yes=\"#ff7315\", no=\"#8cba51\")\n",
    "g = sns.FacetGrid(insurance, col=\"region\" , row = \"sex\" , hue=\"smoker\" ,height=3, aspect=1, palette=pal1)\n",
    "g = g.map(plt.scatter, \"bmi\" , \"charges\",edgecolor=\"w\", s=70)\n",
    "g.add_legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 498,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 173256 characters]\n",
      "text/plain": [
       "<Figure size 1273.88x600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pal1 = dict(yes=\"#ff7315\", no=\"#8cba51\")\n",
    "kws = dict(s=80, linewidth=1, edgecolor=\"w\")\n",
    "kws1 =  dict(height=3, aspect=1,palette=pal1)\n",
    "g = sns.FacetGrid(insurance, col=\"region\" , row = \"sex\" , hue=\"smoker\" , **kws1)\n",
    "g = g.map(plt.scatter, \"bmi\" , \"charges\",**kws)\n",
    "g.add_legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 500,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 143180 characters]\n",
      "text/plain": [
       "<Figure size 1273.88x600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Use different markers for each level of the hue variable\n",
    "pal1 = dict(yes=\"#ff7315\", no=\"#8cba51\")\n",
    "kws = dict(s=70, linewidth=1, edgecolor=\"w\")\n",
    "kws1 =  dict(height=3, aspect=1,palette=pal1 , hue_kws=dict(marker=[\"^\", \"v\"]))\n",
    "g = sns.FacetGrid(insurance, col=\"region\" , row = \"sex\" , hue=\"smoker\" , **kws1)\n",
    "g = g.map(plt.scatter, \"bmi\" , \"charges\",**kws)\n",
    "g.add_legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 502,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.FacetGrid at 0x22ebf1605f8>"
      ]
     },
     "execution_count": 502,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 55732 characters]\n",
      "text/plain": [
       "<Figure size 1211.11x600 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "g = sns.FacetGrid(insurance, col=\"region\" , row = \"sex\" ,height=3, aspect=1)\n",
    "g = g.map(plt.bar, \"smoker\" , \"charges\",edgecolor=\"w\" , color = '#8cba51')\n",
    "g.add_legend()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 503,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>#</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type 1</th>\n",
       "      <th>Type 2</th>\n",
       "      <th>HP</th>\n",
       "      <th>Attack</th>\n",
       "      <th>Defense</th>\n",
       "      <th>Sp. Atk</th>\n",
       "      <th>Sp. Def</th>\n",
       "      <th>Speed</th>\n",
       "      <th>Generation</th>\n",
       "      <th>Legendary</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Bulbasaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>45</td>\n",
       "      <td>49</td>\n",
       "      <td>49</td>\n",
       "      <td>65</td>\n",
       "      <td>65</td>\n",
       "      <td>45</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>318</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Ivysaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>60</td>\n",
       "      <td>62</td>\n",
       "      <td>63</td>\n",
       "      <td>80</td>\n",
       "      <td>80</td>\n",
       "      <td>60</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>405</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Venusaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>80</td>\n",
       "      <td>82</td>\n",
       "      <td>83</td>\n",
       "      <td>100</td>\n",
       "      <td>100</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>525</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>VenusaurMega Venusaur</td>\n",
       "      <td>Grass</td>\n",
       "      <td>Poison</td>\n",
       "      <td>80</td>\n",
       "      <td>100</td>\n",
       "      <td>123</td>\n",
       "      <td>122</td>\n",
       "      <td>120</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>Charmander</td>\n",
       "      <td>Fire</td>\n",
       "      <td>NaN</td>\n",
       "      <td>39</td>\n",
       "      <td>52</td>\n",
       "      <td>43</td>\n",
       "      <td>60</td>\n",
       "      <td>50</td>\n",
       "      <td>65</td>\n",
       "      <td>1</td>\n",
       "      <td>False</td>\n",
       "      <td>309</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   #                   Name Type 1  Type 2  HP  Attack  Defense  Sp. Atk  \\\n",
       "0  1              Bulbasaur  Grass  Poison  45      49       49       65   \n",
       "1  2                Ivysaur  Grass  Poison  60      62       63       80   \n",
       "2  3               Venusaur  Grass  Poison  80      82       83      100   \n",
       "3  3  VenusaurMega Venusaur  Grass  Poison  80     100      123      122   \n",
       "4  4             Charmander   Fire     NaN  39      52       43       60   \n",
       "\n",
       "   Sp. Def  Speed  Generation  Legendary  Total  \n",
       "0       65     45           1      False    318  \n",
       "1       80     60           1      False    405  \n",
       "2      100     80           1      False    525  \n",
       "3      120     80           1      False    625  \n",
       "4       50     65           1      False    309  "
      ]
     },
     "execution_count": 503,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pokemon.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 510,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 143388 characters]\n",
      "text/plain": [
       "<Figure size 840x1680 with 18 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Limiting the number of columns using \"col_wrap\"\n",
    "g = sns.FacetGrid(pokemon, col=\"Type 2\" , col_wrap=3 , height=2.8, aspect=1)\n",
    "g = g.map(plt.scatter, \"Attack\" , \"Sp. Atk\",color = '#FF6600',edgecolor=\"w\", s=70)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Joint Plot\n",
    "\n",
    "#### Joint plot is used to draw a plot of two variables with bivariate graph and univariate graphs in the margin."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 627,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 628,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>sex</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>smoker</th>\n",
       "      <th>region</th>\n",
       "      <th>charges</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "      <td>southwest</td>\n",
       "      <td>16884.92400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>1725.55230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>male</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>4449.46200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>male</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>21984.47061</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>male</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>3866.85520</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     sex     bmi  children smoker     region      charges\n",
       "0   19  female  27.900         0    yes  southwest  16884.92400\n",
       "1   18    male  33.770         1     no  southeast   1725.55230\n",
       "2   28    male  33.000         3     no  southeast   4449.46200\n",
       "3   33    male  22.705         0     no  northwest  21984.47061\n",
       "4   32    male  28.880         0     no  northwest   3866.85520"
      ]
     },
     "execution_count": 628,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "insurance.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 629,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec4a64898>"
      ]
     },
     "execution_count": 629,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 54112 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# scatterplot with marginal histograms\n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 630,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec4b755f8>"
      ]
     },
     "execution_count": 630,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 101560 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Regplot with marginal distplot\n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"reg\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 631,
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.set(style=\"white\", color_codes=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 632,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec4dbc9e8>"
      ]
     },
     "execution_count": 632,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 57064 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 633,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec4edc780>"
      ]
     },
     "execution_count": 633,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 89372 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Resid Plot\n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"resid\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 561,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ebbe178d0>"
      ]
     },
     "execution_count": 561,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 48992 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# \"ratio\" adjusts the relative size of the marginal plots\n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10, ratio=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 517,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 97560 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Change the color of the joint plot\n",
    "g = sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , color = '#FF6600',edgecolor=\"w\", s=90 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 518,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 117336 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.rcParams['figure.facecolor'] = \"#E5E7E9\"\n",
    "plt.rcParams['axes.facecolor'] = \"#E5E7E9\"\n",
    "plt.rcParams[ 'axes.labelsize'] = 20\n",
    "plt.rcParams['xtick.labelsize'] = 15\n",
    "plt.rcParams['ytick.labelsize'] = 15\n",
    "g = sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , color = '#FF6600',edgecolor=\"w\", s=90 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 521,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Recover default matplotlib settings\n",
    "mpl.rcParams.update(mpl.rcParamsDefault)\n",
    "%matplotlib inline\n",
    "sns.set(style=\"white\", color_codes=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 541,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec2387d68>"
      ]
     },
     "execution_count": 541,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 83124 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Replace the scatterplot with a joint histogram using hexagonal bins\n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"hex\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 542,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec2728828>"
      ]
     },
     "execution_count": 542,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 80076 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Replace the scatterplot with a joint histogram using hexagonal bins\n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"hex\" , color=\"#fb9224\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 540,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec2454a90>"
      ]
     },
     "execution_count": 540,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 34840 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\" Replace the scatterplot & joint histogram with kde plot\n",
    "     in the margins and the interior into a shaded countour plot  \"\"\"\n",
    "\n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"kde\" , color=\"#FF6600\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 580,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec0202048>"
      ]
     },
     "execution_count": 580,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 30812 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Create Space between the joint and marginal axes\n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"kde\" , color=\"#FF6600\", space=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 609,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ebfdb1358>"
      ]
     },
     "execution_count": 609,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 30868 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Set Axis limits \n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"kde\" , \n",
    "              color=\"#FF6600\", space=2, xlim=(0,50),ylim=(-3000,70000))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 589,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec0e29358>"
      ]
     },
     "execution_count": 589,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 36072 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Change formatting of marginal graphs\n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"kde\" , \n",
    "              color=\"#FF6600\" , marginal_kws={'lw':5})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 613,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec2b800b8>"
      ]
     },
     "execution_count": 613,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 36144 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Change formatting of marginal graphs\n",
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"kde\" , \n",
    "              color=\"#33CC00\" , marginal_kws={'lw':5 , 'color' : \"#FF3300\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 615,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ec2cbcb38>"
      ]
     },
     "execution_count": 615,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 40484 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"kde\" , \n",
    "              color=\"#33CC00\" , marginal_kws={'lw':5 , 'color' : \"#FF3300\" , 'bw' :.3})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 624,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 38280 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing background of marginal graphs\n",
    "g = sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"kde\" , \n",
    "              color=\"#33CC00\" , marginal_kws={'lw':5 , 'color' : \"#FF3300\"})\n",
    "g.ax_marg_x.set_facecolor('#f8fab8')\n",
    "g.ax_marg_y.set_facecolor('#f8fab8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 539,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<seaborn.axisgrid.JointGrid at 0x22ebb1e42b0>"
      ]
     },
     "execution_count": 539,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 83524 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Defining Axis Labels\n",
    "(sns.jointplot(x=\"bmi\", y=\"charges\", data=insurance , height = 10 , kind=\"hex\" , color=\"#a0c334\")\n",
    "     .set_axis_labels(\"$BMI$\", \"$CHARGES$\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 538,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 108068 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.jointplot(\"bmi\", \"charges\", data=insurance,  s=70, edgecolor=\"w\", linewidth=1, height = 10 , color=\"#58b368\",\n",
    "              marginal_kws=dict(bins=15, rug=True))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Joint Grid\n",
    "\n",
    "#### Grid for drawing a bivariate plot with marginal univariate plots."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 639,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 103104 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Add plots using default parameters\n",
    "g = sns.JointGrid(x=\"bmi\", y=\"charges\", data=insurance, height = 10)\n",
    "g = g.plot(sns.regplot, sns.distplot)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 650,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 90388 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing color of plots\n",
    "g = sns.JointGrid(x=\"bmi\", y=\"charges\", data=insurance, height = 10)\n",
    "g = g.plot_joint(sns.scatterplot, color=\"#FF6600\",s=50)\n",
    "g = g.plot_marginals(sns.distplot, color=\"#FF6600\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 646,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 71652 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Remove kernel density estimate from the marginal plots\n",
    "g = sns.JointGrid(x=\"bmi\", y=\"charges\", data=insurance, height = 10)\n",
    "g = g.plot_joint(sns.scatterplot, color=\"#FF6600\")\n",
    "g = g.plot_marginals(sns.distplot,kde= False, color=\"#FF6600\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 808,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 71052 characters]\n",
      "text/plain": [
       "<Figure size 576x576 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# kde plot in the margins and the interior into a shaded countour plot\n",
    "g = sns.JointGrid(x=\"bmi\", y=\"charges\", data=insurance, height = 8)\n",
    "g = g.plot_joint(sns.kdeplot)\n",
    "g = g.plot_marginals(sns.kdeplot, shade=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 809,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 71948 characters]\n",
      "text/plain": [
       "<Figure size 576x576 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Remove the space between the joint and marginal axes\n",
    "g = sns.JointGrid(x=\"bmi\", y=\"charges\", data=insurance, height = 8 , space =0)\n",
    "g = g.plot_joint(sns.kdeplot)\n",
    "g = g.plot_marginals(sns.kdeplot, shade=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 658,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 67524 characters]\n",
      "text/plain": [
       "<Figure size 576x576 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "g = sns.JointGrid(x=\"bmi\", y=\"charges\", data=insurance, height = 8)\n",
    "g = g.plot_joint(sns.kdeplot , cmap=\"OrRd_r\")\n",
    "g = g.plot_marginals(sns.kdeplot, shade=True , color = 'orange')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 665,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 99164 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Set Axis limits \n",
    "g = sns.JointGrid(x=\"bmi\", y=\"charges\", data=insurance, height = 10 , xlim=(10,50) , ylim=(-3000,60000))\n",
    "g = g.plot_joint(sns.kdeplot , cmap=\"OrRd_r\")\n",
    "g = g.plot_marginals(sns.kdeplot, shade=True , color = 'orange')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 673,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 87196 characters]\n",
      "text/plain": [
       "<Figure size 720x720 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Changing background of marginal graphs\n",
    "g = sns.JointGrid(x=\"bmi\", y=\"charges\", data=insurance, height = 10 , xlim=(10,50) , ylim=(-3000,60000) )\n",
    "g = g.plot_joint(sns.scatterplot, color=\"#FF6600\",s=50)\n",
    "g= g.plot_marginals(sns.distplot,kde=False , color = 'Blue')\n",
    "g.ax_marg_x.set_facecolor('#f8fab8')\n",
    "g.ax_marg_y.set_facecolor('#f8fab8')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ***************END***********"
   ]
  }
 ],
 "metadata": {
  "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.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
