{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "s = pd.Series(['banana', 42])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    banana\n",
       "1        42\n",
       "dtype: object"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "s = pd.Series(['Wes', 'Creater'], index=['person', 'who'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "person        Wes\n",
       "who       Creater\n",
       "dtype: object"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Wes'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.loc['person']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Wes'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "scientists=pd.DataFrame(\n",
    "data={'Occupation':['Chemist','Statistician'],\n",
    "'Born':['1920-07-25', '1876-06-13'],\n",
    "'Died':['1958-04-16', '1937-10-16'],\n",
    "'Age':[37,61]},\n",
    "index=['Rosaline Franklin','William Gosset'],\n",
    "columns=['Occupation', 'Born','Died','Age'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Occupation</th>\n",
       "      <th>Born</th>\n",
       "      <th>Died</th>\n",
       "      <th>Age</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Rosaline Franklin</th>\n",
       "      <td>Chemist</td>\n",
       "      <td>1920-07-25</td>\n",
       "      <td>1958-04-16</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>William Gosset</th>\n",
       "      <td>Statistician</td>\n",
       "      <td>1876-06-13</td>\n",
       "      <td>1937-10-16</td>\n",
       "      <td>61</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Occupation        Born        Died  Age\n",
       "Rosaline Franklin       Chemist  1920-07-25  1958-04-16   37\n",
       "William Gosset     Statistician  1876-06-13  1937-10-16   61"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scientists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "scientists = pd.read_csv('../data/scientists.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Born</th>\n",
       "      <th>Died</th>\n",
       "      <th>Age</th>\n",
       "      <th>Occupation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Rosaline Franklin</td>\n",
       "      <td>1920-07-25</td>\n",
       "      <td>1958-04-16</td>\n",
       "      <td>37</td>\n",
       "      <td>Chemist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>William Gosset</td>\n",
       "      <td>1876-06-13</td>\n",
       "      <td>1937-10-16</td>\n",
       "      <td>61</td>\n",
       "      <td>Statistician</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Florence Nightingale</td>\n",
       "      <td>1820-05-12</td>\n",
       "      <td>1910-08-13</td>\n",
       "      <td>90</td>\n",
       "      <td>Nurse</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Marie Curie</td>\n",
       "      <td>1867-11-07</td>\n",
       "      <td>1934-07-04</td>\n",
       "      <td>66</td>\n",
       "      <td>Chemist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Rachel Carson</td>\n",
       "      <td>1907-05-27</td>\n",
       "      <td>1964-04-14</td>\n",
       "      <td>56</td>\n",
       "      <td>Biologist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>John Snow</td>\n",
       "      <td>1813-03-15</td>\n",
       "      <td>1858-06-16</td>\n",
       "      <td>45</td>\n",
       "      <td>Physician</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Alan Turing</td>\n",
       "      <td>1912-06-23</td>\n",
       "      <td>1954-06-07</td>\n",
       "      <td>41</td>\n",
       "      <td>Computer Scientist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Johann Gauss</td>\n",
       "      <td>1777-04-30</td>\n",
       "      <td>1855-02-23</td>\n",
       "      <td>77</td>\n",
       "      <td>Mathematician</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Name        Born        Died  Age          Occupation\n",
       "0     Rosaline Franklin  1920-07-25  1958-04-16   37             Chemist\n",
       "1        William Gosset  1876-06-13  1937-10-16   61        Statistician\n",
       "2  Florence Nightingale  1820-05-12  1910-08-13   90               Nurse\n",
       "3           Marie Curie  1867-11-07  1934-07-04   66             Chemist\n",
       "4         Rachel Carson  1907-05-27  1964-04-14   56           Biologist\n",
       "5             John Snow  1813-03-15  1858-06-16   45           Physician\n",
       "6           Alan Turing  1912-06-23  1954-06-07   41  Computer Scientist\n",
       "7          Johann Gauss  1777-04-30  1855-02-23   77       Mathematician"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scientists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "ages = scientists['Age']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    37\n",
       "1    61\n",
       "2    90\n",
       "3    66\n",
       "4    56\n",
       "5    45\n",
       "6    41\n",
       "7    77\n",
       "Name: Age, dtype: int64"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    37\n",
       "1    61\n",
       "2    90\n",
       "3    66\n",
       "4    56\n",
       "5    45\n",
       "6    41\n",
       "7    77\n",
       "Name: Age, dtype: int64"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages = scientists.Age\n",
    "ages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(8, 5)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# if shape is a column name you *have* to use square brackets\n",
    "# scientists['shape']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(ages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "59.125"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(8,)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "37"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count     8.000000\n",
       "mean     59.125000\n",
       "std      18.325918\n",
       "min      37.000000\n",
       "25%      44.000000\n",
       "50%      58.500000\n",
       "75%      68.750000\n",
       "max      90.000000\n",
       "Name: Age, dtype: float64"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1    61\n",
       "2    90\n",
       "3    66\n",
       "7    77\n",
       "Name: Age, dtype: int64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages[ages > ages.mean()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2    90\n",
       "7    77\n",
       "Name: Age, dtype: int64"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages[(ages > ages.mean()) & (ages > 75)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "cannot compare a dtyped [int64] array with a scalar of type [bool]",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\ops.py\u001b[0m in \u001b[0;36mna_op\u001b[1;34m(x, y)\u001b[0m\n\u001b[0;32m    882\u001b[0m         \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 883\u001b[1;33m             \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    884\u001b[0m         \u001b[1;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\ops.py\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(x, y)\u001b[0m\n\u001b[0;32m    128\u001b[0m                  \u001b[0mxor\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mbool_method\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0moperator\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mxor\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnames\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'xor'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'^'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 129\u001b[1;33m                  rand_=bool_method(lambda x, y: operator.and_(y, x),\n\u001b[0m\u001b[0;32m    130\u001b[0m                                    names('rand_'), op('&')),\n",
      "\u001b[1;31mTypeError\u001b[0m: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\ops.py\u001b[0m in \u001b[0;36mna_op\u001b[1;34m(x, y)\u001b[0m\n\u001b[0;32m    900\u001b[0m                         \u001b[0my\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mbool\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 901\u001b[1;33m                     \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mscalar_binop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mop\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    902\u001b[0m                 \u001b[1;32mexcept\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\lib.pyx\u001b[0m in \u001b[0;36mpandas._libs.lib.scalar_binop\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;31mValueError\u001b[0m: Buffer dtype mismatch, expected 'Python object' but got 'long long'",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-30-38ee68db636b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mages\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mages\u001b[0m \u001b[1;33m>\u001b[0m \u001b[0mages\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmean\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m&\u001b[0m \u001b[0mages\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m75\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\ops.py\u001b[0m in \u001b[0;36mwrapper\u001b[1;34m(self, other)\u001b[0m\n\u001b[0;32m    933\u001b[0m                       is_integer_dtype(np.asarray(other)) else fill_bool)\n\u001b[0;32m    934\u001b[0m             return filler(self._constructor(\n\u001b[1;32m--> 935\u001b[1;33m                 \u001b[0mna_op\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    936\u001b[0m                 index=self.index)).__finalize__(self)\n\u001b[0;32m    937\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\Anaconda3\\lib\\site-packages\\pandas\\core\\ops.py\u001b[0m in \u001b[0;36mna_op\u001b[1;34m(x, y)\u001b[0m\n\u001b[0;32m    903\u001b[0m                     raise TypeError(\"cannot compare a dtyped [{0}] array with \"\n\u001b[0;32m    904\u001b[0m                                     \"a scalar of type [{1}]\".format(\n\u001b[1;32m--> 905\u001b[1;33m                                         x.dtype, type(y).__name__))\n\u001b[0m\u001b[0;32m    906\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    907\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mTypeError\u001b[0m: cannot compare a dtyped [int64] array with a scalar of type [bool]"
     ]
    }
   ],
   "source": [
    "ages[ages > ages.mean() & ages > 75]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1    61\n",
       "3    66\n",
       "Name: Age, dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages[(ages > ages.mean()) & ~(ages > 75)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count     8.000000\n",
       "mean     59.125000\n",
       "std      18.325918\n",
       "min      37.000000\n",
       "25%      44.000000\n",
       "50%      58.500000\n",
       "75%      68.750000\n",
       "max      90.000000\n",
       "Name: Age, dtype: float64"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    137\n",
       "1    161\n",
       "2    190\n",
       "3    166\n",
       "4    156\n",
       "5    145\n",
       "6    141\n",
       "7    177\n",
       "Name: Age, dtype: int64"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ages + 100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Born</th>\n",
       "      <th>Died</th>\n",
       "      <th>Age</th>\n",
       "      <th>Occupation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Rosaline Franklin</td>\n",
       "      <td>1920-07-25</td>\n",
       "      <td>1958-04-16</td>\n",
       "      <td>37</td>\n",
       "      <td>Chemist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>William Gosset</td>\n",
       "      <td>1876-06-13</td>\n",
       "      <td>1937-10-16</td>\n",
       "      <td>61</td>\n",
       "      <td>Statistician</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Florence Nightingale</td>\n",
       "      <td>1820-05-12</td>\n",
       "      <td>1910-08-13</td>\n",
       "      <td>90</td>\n",
       "      <td>Nurse</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Marie Curie</td>\n",
       "      <td>1867-11-07</td>\n",
       "      <td>1934-07-04</td>\n",
       "      <td>66</td>\n",
       "      <td>Chemist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Rachel Carson</td>\n",
       "      <td>1907-05-27</td>\n",
       "      <td>1964-04-14</td>\n",
       "      <td>56</td>\n",
       "      <td>Biologist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>John Snow</td>\n",
       "      <td>1813-03-15</td>\n",
       "      <td>1858-06-16</td>\n",
       "      <td>45</td>\n",
       "      <td>Physician</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Alan Turing</td>\n",
       "      <td>1912-06-23</td>\n",
       "      <td>1954-06-07</td>\n",
       "      <td>41</td>\n",
       "      <td>Computer Scientist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Johann Gauss</td>\n",
       "      <td>1777-04-30</td>\n",
       "      <td>1855-02-23</td>\n",
       "      <td>77</td>\n",
       "      <td>Mathematician</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Name        Born        Died  Age          Occupation\n",
       "0     Rosaline Franklin  1920-07-25  1958-04-16   37             Chemist\n",
       "1        William Gosset  1876-06-13  1937-10-16   61        Statistician\n",
       "2  Florence Nightingale  1820-05-12  1910-08-13   90               Nurse\n",
       "3           Marie Curie  1867-11-07  1934-07-04   66             Chemist\n",
       "4         Rachel Carson  1907-05-27  1964-04-14   56           Biologist\n",
       "5             John Snow  1813-03-15  1858-06-16   45           Physician\n",
       "6           Alan Turing  1912-06-23  1954-06-07   41  Computer Scientist\n",
       "7          Johann Gauss  1777-04-30  1855-02-23   77       Mathematician"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scientists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Born</th>\n",
       "      <th>Died</th>\n",
       "      <th>Age</th>\n",
       "      <th>Occupation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>William Gosset</td>\n",
       "      <td>1876-06-13</td>\n",
       "      <td>1937-10-16</td>\n",
       "      <td>61</td>\n",
       "      <td>Statistician</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Florence Nightingale</td>\n",
       "      <td>1820-05-12</td>\n",
       "      <td>1910-08-13</td>\n",
       "      <td>90</td>\n",
       "      <td>Nurse</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Marie Curie</td>\n",
       "      <td>1867-11-07</td>\n",
       "      <td>1934-07-04</td>\n",
       "      <td>66</td>\n",
       "      <td>Chemist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Johann Gauss</td>\n",
       "      <td>1777-04-30</td>\n",
       "      <td>1855-02-23</td>\n",
       "      <td>77</td>\n",
       "      <td>Mathematician</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Name        Born        Died  Age     Occupation\n",
       "1        William Gosset  1876-06-13  1937-10-16   61   Statistician\n",
       "2  Florence Nightingale  1820-05-12  1910-08-13   90          Nurse\n",
       "3           Marie Curie  1867-11-07  1934-07-04   66        Chemist\n",
       "7          Johann Gauss  1777-04-30  1855-02-23   77  Mathematician"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scientists[scientists['Age'] > scientists['Age'].mean()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    False\n",
       "1     True\n",
       "2     True\n",
       "3     True\n",
       "4    False\n",
       "5    False\n",
       "6    False\n",
       "7     True\n",
       "Name: Age, dtype: bool"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scientists['Age'] > scientists['Age'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Born</th>\n",
       "      <th>Died</th>\n",
       "      <th>Age</th>\n",
       "      <th>Occupation</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Rosaline Franklin</td>\n",
       "      <td>1920-07-25</td>\n",
       "      <td>1958-04-16</td>\n",
       "      <td>37</td>\n",
       "      <td>Chemist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>William Gosset</td>\n",
       "      <td>1876-06-13</td>\n",
       "      <td>1937-10-16</td>\n",
       "      <td>61</td>\n",
       "      <td>Statistician</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Florence Nightingale</td>\n",
       "      <td>1820-05-12</td>\n",
       "      <td>1910-08-13</td>\n",
       "      <td>90</td>\n",
       "      <td>Nurse</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Marie Curie</td>\n",
       "      <td>1867-11-07</td>\n",
       "      <td>1934-07-04</td>\n",
       "      <td>66</td>\n",
       "      <td>Chemist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Rachel Carson</td>\n",
       "      <td>1907-05-27</td>\n",
       "      <td>1964-04-14</td>\n",
       "      <td>56</td>\n",
       "      <td>Biologist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>John Snow</td>\n",
       "      <td>1813-03-15</td>\n",
       "      <td>1858-06-16</td>\n",
       "      <td>45</td>\n",
       "      <td>Physician</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Alan Turing</td>\n",
       "      <td>1912-06-23</td>\n",
       "      <td>1954-06-07</td>\n",
       "      <td>41</td>\n",
       "      <td>Computer Scientist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Johann Gauss</td>\n",
       "      <td>1777-04-30</td>\n",
       "      <td>1855-02-23</td>\n",
       "      <td>77</td>\n",
       "      <td>Mathematician</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Name        Born        Died  Age          Occupation\n",
       "0     Rosaline Franklin  1920-07-25  1958-04-16   37             Chemist\n",
       "1        William Gosset  1876-06-13  1937-10-16   61        Statistician\n",
       "2  Florence Nightingale  1820-05-12  1910-08-13   90               Nurse\n",
       "3           Marie Curie  1867-11-07  1934-07-04   66             Chemist\n",
       "4         Rachel Carson  1907-05-27  1964-04-14   56           Biologist\n",
       "5             John Snow  1813-03-15  1858-06-16   45           Physician\n",
       "6           Alan Turing  1912-06-23  1954-06-07   41  Computer Scientist\n",
       "7          Johann Gauss  1777-04-30  1855-02-23   77       Mathematician"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scientists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Name          object\n",
       "Born          object\n",
       "Died          object\n",
       "Age            int64\n",
       "Occupation    object\n",
       "dtype: object"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scientists.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "# strftime\n",
    "born_datetime = pd.to_datetime(scientists['Born'], format='%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "pd.to_datetime?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0   1920-07-25\n",
       "1   1876-06-13\n",
       "2   1820-05-12\n",
       "3   1867-11-07\n",
       "4   1907-05-27\n",
       "5   1813-03-15\n",
       "6   1912-06-23\n",
       "7   1777-04-30\n",
       "Name: Born, dtype: datetime64[ns]"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "born_datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "scientists['born_dt'] = born_datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "# same as above\n",
    "scientists['born_dt'] = pd.to_datetime(scientists['Born'], format='%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Born</th>\n",
       "      <th>Died</th>\n",
       "      <th>Age</th>\n",
       "      <th>Occupation</th>\n",
       "      <th>born_dt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Rosaline Franklin</td>\n",
       "      <td>1920-07-25</td>\n",
       "      <td>1958-04-16</td>\n",
       "      <td>37</td>\n",
       "      <td>Chemist</td>\n",
       "      <td>1920-07-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>William Gosset</td>\n",
       "      <td>1876-06-13</td>\n",
       "      <td>1937-10-16</td>\n",
       "      <td>61</td>\n",
       "      <td>Statistician</td>\n",
       "      <td>1876-06-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Florence Nightingale</td>\n",
       "      <td>1820-05-12</td>\n",
       "      <td>1910-08-13</td>\n",
       "      <td>90</td>\n",
       "      <td>Nurse</td>\n",
       "      <td>1820-05-12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Marie Curie</td>\n",
       "      <td>1867-11-07</td>\n",
       "      <td>1934-07-04</td>\n",
       "      <td>66</td>\n",
       "      <td>Chemist</td>\n",
       "      <td>1867-11-07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Rachel Carson</td>\n",
       "      <td>1907-05-27</td>\n",
       "      <td>1964-04-14</td>\n",
       "      <td>56</td>\n",
       "      <td>Biologist</td>\n",
       "      <td>1907-05-27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>John Snow</td>\n",
       "      <td>1813-03-15</td>\n",
       "      <td>1858-06-16</td>\n",
       "      <td>45</td>\n",
       "      <td>Physician</td>\n",
       "      <td>1813-03-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Alan Turing</td>\n",
       "      <td>1912-06-23</td>\n",
       "      <td>1954-06-07</td>\n",
       "      <td>41</td>\n",
       "      <td>Computer Scientist</td>\n",
       "      <td>1912-06-23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Johann Gauss</td>\n",
       "      <td>1777-04-30</td>\n",
       "      <td>1855-02-23</td>\n",
       "      <td>77</td>\n",
       "      <td>Mathematician</td>\n",
       "      <td>1777-04-30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Name        Born        Died  Age          Occupation  \\\n",
       "0     Rosaline Franklin  1920-07-25  1958-04-16   37             Chemist   \n",
       "1        William Gosset  1876-06-13  1937-10-16   61        Statistician   \n",
       "2  Florence Nightingale  1820-05-12  1910-08-13   90               Nurse   \n",
       "3           Marie Curie  1867-11-07  1934-07-04   66             Chemist   \n",
       "4         Rachel Carson  1907-05-27  1964-04-14   56           Biologist   \n",
       "5             John Snow  1813-03-15  1858-06-16   45           Physician   \n",
       "6           Alan Turing  1912-06-23  1954-06-07   41  Computer Scientist   \n",
       "7          Johann Gauss  1777-04-30  1855-02-23   77       Mathematician   \n",
       "\n",
       "     born_dt  \n",
       "0 1920-07-25  \n",
       "1 1876-06-13  \n",
       "2 1820-05-12  \n",
       "3 1867-11-07  \n",
       "4 1907-05-27  \n",
       "5 1813-03-15  \n",
       "6 1912-06-23  \n",
       "7 1777-04-30  "
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scientists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 8 entries, 0 to 7\n",
      "Data columns (total 6 columns):\n",
      "Name          8 non-null object\n",
      "Born          8 non-null object\n",
      "Died          8 non-null object\n",
      "Age           8 non-null int64\n",
      "Occupation    8 non-null object\n",
      "born_dt       8 non-null datetime64[ns]\n",
      "dtypes: datetime64[ns](1), int64(1), object(4)\n",
      "memory usage: 464.0+ bytes\n"
     ]
    }
   ],
   "source": [
    "scientists.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Born</th>\n",
       "      <th>Died</th>\n",
       "      <th>Age</th>\n",
       "      <th>Occupation</th>\n",
       "      <th>born_dt</th>\n",
       "      <th>died_dt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Rosaline Franklin</td>\n",
       "      <td>1920-07-25</td>\n",
       "      <td>1958-04-16</td>\n",
       "      <td>37</td>\n",
       "      <td>Chemist</td>\n",
       "      <td>1920-07-25</td>\n",
       "      <td>1958-04-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>William Gosset</td>\n",
       "      <td>1876-06-13</td>\n",
       "      <td>1937-10-16</td>\n",
       "      <td>61</td>\n",
       "      <td>Statistician</td>\n",
       "      <td>1876-06-13</td>\n",
       "      <td>1937-10-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Florence Nightingale</td>\n",
       "      <td>1820-05-12</td>\n",
       "      <td>1910-08-13</td>\n",
       "      <td>90</td>\n",
       "      <td>Nurse</td>\n",
       "      <td>1820-05-12</td>\n",
       "      <td>1910-08-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Marie Curie</td>\n",
       "      <td>1867-11-07</td>\n",
       "      <td>1934-07-04</td>\n",
       "      <td>66</td>\n",
       "      <td>Chemist</td>\n",
       "      <td>1867-11-07</td>\n",
       "      <td>1934-07-04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Rachel Carson</td>\n",
       "      <td>1907-05-27</td>\n",
       "      <td>1964-04-14</td>\n",
       "      <td>56</td>\n",
       "      <td>Biologist</td>\n",
       "      <td>1907-05-27</td>\n",
       "      <td>1964-04-14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>John Snow</td>\n",
       "      <td>1813-03-15</td>\n",
       "      <td>1858-06-16</td>\n",
       "      <td>45</td>\n",
       "      <td>Physician</td>\n",
       "      <td>1813-03-15</td>\n",
       "      <td>1858-06-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Alan Turing</td>\n",
       "      <td>1912-06-23</td>\n",
       "      <td>1954-06-07</td>\n",
       "      <td>41</td>\n",
       "      <td>Computer Scientist</td>\n",
       "      <td>1912-06-23</td>\n",
       "      <td>1954-06-07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Johann Gauss</td>\n",
       "      <td>1777-04-30</td>\n",
       "      <td>1855-02-23</td>\n",
       "      <td>77</td>\n",
       "      <td>Mathematician</td>\n",
       "      <td>1777-04-30</td>\n",
       "      <td>1855-02-23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Name        Born        Died  Age          Occupation  \\\n",
       "0     Rosaline Franklin  1920-07-25  1958-04-16   37             Chemist   \n",
       "1        William Gosset  1876-06-13  1937-10-16   61        Statistician   \n",
       "2  Florence Nightingale  1820-05-12  1910-08-13   90               Nurse   \n",
       "3           Marie Curie  1867-11-07  1934-07-04   66             Chemist   \n",
       "4         Rachel Carson  1907-05-27  1964-04-14   56           Biologist   \n",
       "5             John Snow  1813-03-15  1858-06-16   45           Physician   \n",
       "6           Alan Turing  1912-06-23  1954-06-07   41  Computer Scientist   \n",
       "7          Johann Gauss  1777-04-30  1855-02-23   77       Mathematician   \n",
       "\n",
       "     born_dt    died_dt  \n",
       "0 1920-07-25 1958-04-16  \n",
       "1 1876-06-13 1937-10-16  \n",
       "2 1820-05-12 1910-08-13  \n",
       "3 1867-11-07 1934-07-04  \n",
       "4 1907-05-27 1964-04-14  \n",
       "5 1813-03-15 1858-06-16  \n",
       "6 1912-06-23 1954-06-07  \n",
       "7 1777-04-30 1855-02-23  "
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scientists['died_dt'] = pd.to_datetime(scientists['Died'], format='%Y-%m-%d')\n",
    "scientists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "scientists = scientists.drop(['Born', 'Died'], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Age</th>\n",
       "      <th>Occupation</th>\n",
       "      <th>born_dt</th>\n",
       "      <th>died_dt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Rosaline Franklin</td>\n",
       "      <td>37</td>\n",
       "      <td>Chemist</td>\n",
       "      <td>1920-07-25</td>\n",
       "      <td>1958-04-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>William Gosset</td>\n",
       "      <td>61</td>\n",
       "      <td>Statistician</td>\n",
       "      <td>1876-06-13</td>\n",
       "      <td>1937-10-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Florence Nightingale</td>\n",
       "      <td>90</td>\n",
       "      <td>Nurse</td>\n",
       "      <td>1820-05-12</td>\n",
       "      <td>1910-08-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Marie Curie</td>\n",
       "      <td>66</td>\n",
       "      <td>Chemist</td>\n",
       "      <td>1867-11-07</td>\n",
       "      <td>1934-07-04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Rachel Carson</td>\n",
       "      <td>56</td>\n",
       "      <td>Biologist</td>\n",
       "      <td>1907-05-27</td>\n",
       "      <td>1964-04-14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>John Snow</td>\n",
       "      <td>45</td>\n",
       "      <td>Physician</td>\n",
       "      <td>1813-03-15</td>\n",
       "      <td>1858-06-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Alan Turing</td>\n",
       "      <td>41</td>\n",
       "      <td>Computer Scientist</td>\n",
       "      <td>1912-06-23</td>\n",
       "      <td>1954-06-07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Johann Gauss</td>\n",
       "      <td>77</td>\n",
       "      <td>Mathematician</td>\n",
       "      <td>1777-04-30</td>\n",
       "      <td>1855-02-23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   Name  Age          Occupation    born_dt    died_dt\n",
       "0     Rosaline Franklin   37             Chemist 1920-07-25 1958-04-16\n",
       "1        William Gosset   61        Statistician 1876-06-13 1937-10-16\n",
       "2  Florence Nightingale   90               Nurse 1820-05-12 1910-08-13\n",
       "3           Marie Curie   66             Chemist 1867-11-07 1934-07-04\n",
       "4         Rachel Carson   56           Biologist 1907-05-27 1964-04-14\n",
       "5             John Snow   45           Physician 1813-03-15 1858-06-16\n",
       "6           Alan Turing   41  Computer Scientist 1912-06-23 1954-06-07\n",
       "7          Johann Gauss   77       Mathematician 1777-04-30 1855-02-23"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scientists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "scientists.to_csv('scientists_clean.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                   Name        Born        Died  Age    Occupation\n",
      "0     Rosaline Franklin  1920-07-25  1958-04-16   37       Chemist\n",
      "1        William Gosset  1876-06-13  1937-10-16   61  Statistician\n",
      "2  Florence Nightingale  1820-05-12  1910-08-13   90         Nurse\n",
      "3           Marie Curie  1867-11-07  1934-07-04   66       Chemist\n",
      "4         Rachel Carson  1907-05-27  1964-04-14   56     Biologist\n",
      "                   Name  Age    Occupation\n",
      "0     Rosaline Franklin   37       Chemist\n",
      "1        William Gosset   61  Statistician\n",
      "2  Florence Nightingale   90         Nurse\n",
      "3           Marie Curie   66       Chemist\n",
      "4         Rachel Carson   56     Biologist\n"
     ]
    }
   ],
   "source": [
    "# drop column full example\n",
    "scientists = pd.read_csv('../data/scientists.csv', sep=',') # sep=',' is the default\n",
    "scientists = pd.read_csv('../data/scientists.csv')\n",
    "scientists = pd.read_csv('../data/scientists.csv', ',') # using positional argument passing for sep\n",
    "print(scientists.head())\n",
    "\n",
    "# remember you need to re-assign the 'dropped' dataframe\n",
    "scientists = scientists.drop(['Born', 'Died'], axis=1)\n",
    "print(scientists.head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
