{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "tags": [
     "remove_input"
    ]
   },
   "outputs": [],
   "source": [
    "path_data = '../../data/'\n",
    "\n",
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "tags": [
     "remove_input"
    ]
   },
   "outputs": [],
   "source": [
    "nba_salaries = pd.read_csv(path_data + 'nba_salaries.csv')\n",
    "nba = nba_salaries.rename(columns={\"'15-'16 SALARY\": 'SALARY'})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Selecting Rows\n",
    "\n",
    "Often, we would like to extract just those rows that correspond to entries with a particular feature. For example, we might want only the rows corresponding to the Warriors, or to players who earned more than $\\$10$ million. Or we might just want the top five earners."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Specified Rows\n",
    "The fact that a DataFrame creates an index by default startts to become very useful here as we can specify which rows (by default) we wish to inspect by stating an index or an index range. The argument used a row index or array of indices, and it creates a new DataFrame consisting of only those rows.\n",
    "\n",
    "For example, if we wanted just the first row of `nba`, we could use `df.iloc[]` as follows."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Paul Millsap</td>\n",
       "      <td>PF</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>18.671659</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Al Horford</td>\n",
       "      <td>C</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>12.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Tiago Splitter</td>\n",
       "      <td>C</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>9.756250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Jeff Teague</td>\n",
       "      <td>PG</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>8.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Kyle Korver</td>\n",
       "      <td>SG</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>5.746479</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>412</th>\n",
       "      <td>Gary Neal</td>\n",
       "      <td>PG</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>2.139000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>413</th>\n",
       "      <td>DeJuan Blair</td>\n",
       "      <td>C</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>414</th>\n",
       "      <td>Kelly Oubre Jr.</td>\n",
       "      <td>SF</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>1.920240</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415</th>\n",
       "      <td>Garrett Temple</td>\n",
       "      <td>SG</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>1.100602</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>416</th>\n",
       "      <td>Jarell Eddie</td>\n",
       "      <td>SG</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>0.561716</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>417 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              PLAYER POSITION                TEAM     SALARY\n",
       "0       Paul Millsap       PF       Atlanta Hawks  18.671659\n",
       "1         Al Horford        C       Atlanta Hawks  12.000000\n",
       "2     Tiago Splitter        C       Atlanta Hawks   9.756250\n",
       "3        Jeff Teague       PG       Atlanta Hawks   8.000000\n",
       "4        Kyle Korver       SG       Atlanta Hawks   5.746479\n",
       "..               ...      ...                 ...        ...\n",
       "412        Gary Neal       PG  Washington Wizards   2.139000\n",
       "413     DeJuan Blair        C  Washington Wizards   2.000000\n",
       "414  Kelly Oubre Jr.       SF  Washington Wizards   1.920240\n",
       "415   Garrett Temple       SG  Washington Wizards   1.100602\n",
       "416     Jarell Eddie       SG  Washington Wizards   0.561716\n",
       "\n",
       "[417 rows x 4 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PLAYER       Paul Millsap\n",
       "POSITION               PF\n",
       "TEAM        Atlanta Hawks\n",
       "SALARY            18.6717\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Paul Millsap</td>\n",
       "      <td>PF</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>18.671659</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         PLAYER POSITION           TEAM     SALARY\n",
       "0  Paul Millsap       PF  Atlanta Hawks  18.671659"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba.iloc[[0]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is a new table with just the single row that we specified.\n",
    "\n",
    "We could also get the fourth, fifth, and sixth rows by specifying a range of indices as the argument."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Jeff Teague</td>\n",
       "      <td>PG</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>8.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Kyle Korver</td>\n",
       "      <td>SG</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>5.746479</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Thabo Sefolosha</td>\n",
       "      <td>SF</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            PLAYER POSITION           TEAM    SALARY\n",
       "3      Jeff Teague       PG  Atlanta Hawks  8.000000\n",
       "4      Kyle Korver       SG  Atlanta Hawks  5.746479\n",
       "5  Thabo Sefolosha       SF  Atlanta Hawks  4.000000"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba.iloc[np.arange(3, 6)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If we want a table of the top 5 highest paid players, we can first sort the list by salary and then `df.iloc[]` the first five rows:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>169</th>\n",
       "      <td>Kobe Bryant</td>\n",
       "      <td>SF</td>\n",
       "      <td>Los Angeles Lakers</td>\n",
       "      <td>25.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>Joe Johnson</td>\n",
       "      <td>SF</td>\n",
       "      <td>Brooklyn Nets</td>\n",
       "      <td>24.894863</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>LeBron James</td>\n",
       "      <td>SF</td>\n",
       "      <td>Cleveland Cavaliers</td>\n",
       "      <td>22.970500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255</th>\n",
       "      <td>Carmelo Anthony</td>\n",
       "      <td>SF</td>\n",
       "      <td>New York Knicks</td>\n",
       "      <td>22.875000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>Dwight Howard</td>\n",
       "      <td>C</td>\n",
       "      <td>Houston Rockets</td>\n",
       "      <td>22.359364</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              PLAYER POSITION                 TEAM     SALARY\n",
       "169      Kobe Bryant       SF   Los Angeles Lakers  25.000000\n",
       "29       Joe Johnson       SF        Brooklyn Nets  24.894863\n",
       "72      LeBron James       SF  Cleveland Cavaliers  22.970500\n",
       "255  Carmelo Anthony       SF      New York Knicks  22.875000\n",
       "131    Dwight Howard        C      Houston Rockets  22.359364"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba.sort_values('SALARY', ascending=False).iloc[(np.arange(5))]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Rows Corresponding to a Specified Feature\n",
    "More often, we will want to access data in a set of rows that have a certain feature, but whose indices we don't know ahead of time. For example, we might want data on all the players who made more than $\\$10$ million, but we don't want to spend time counting rows in the sorted table.\n",
    "\n",
    "Array version - if we wish to work with an array we can use `np.where(df['column'] criteria)`.  \n",
    "\n",
    "[np.where()](https://numpy.org/doc/stable/reference/generated/numpy.where.html)\n",
    "\n",
    "DataFrame version - to implement a selection criteria the df is called with selection criteria being applied to the df.col i.e. `df[df['column_name']criteria]`.\n",
    "\n",
    "In the first example, we extract the data for all those who earned more than $\\$10$ million."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([  0,   1,  29,  30,  42,  43,  44,  60,  61,  62,  72,  73,  74,\n",
       "         75,  76,  82,  83,  93,  94,  95, 107, 117, 118, 119, 120, 121,\n",
       "        131, 132, 133, 143, 144, 156, 157, 169, 170, 180, 201, 202, 203,\n",
       "        204, 213, 226, 227, 239, 240, 241, 255, 256, 268, 269, 270, 271,\n",
       "        284, 285, 298, 311, 312, 342, 343, 353, 354, 355, 366, 367, 368,\n",
       "        383, 400, 401, 402]),)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.where(nba['SALARY'] > 10)\n",
    "\n",
    "# or - this is an example of alternatives being available to select,\n",
    "# this may depend upon preference, the task at hand, the impact of processing time or export requirements\n",
    "\n",
    "#nba[nba['SALARY'] >10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The use of the argument `df[df[col] > 10]` ensured that each selected row had a value of `SALARY` that was greater than 10.\n",
    "\n",
    "There are 69 rows in the new table, corresponding to the 69 players who made more than $10$ million dollars. Arranging these rows in order makes the data easier to analyze. DeMar DeRozan of the Toronto Raptors was the \"poorest\" of this group, at a salary of just over $10$ million dollars."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>368</th>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>SG</td>\n",
       "      <td>Toronto Raptors</td>\n",
       "      <td>10.050000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>298</th>\n",
       "      <td>Gerald Wallace</td>\n",
       "      <td>SF</td>\n",
       "      <td>Philadelphia 76ers</td>\n",
       "      <td>10.105855</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204</th>\n",
       "      <td>Luol Deng</td>\n",
       "      <td>SF</td>\n",
       "      <td>Miami Heat</td>\n",
       "      <td>10.151612</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>144</th>\n",
       "      <td>Monta Ellis</td>\n",
       "      <td>SG</td>\n",
       "      <td>Indiana Pacers</td>\n",
       "      <td>10.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>95</th>\n",
       "      <td>Wilson Chandler</td>\n",
       "      <td>SF</td>\n",
       "      <td>Denver Nuggets</td>\n",
       "      <td>10.449438</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>Dwight Howard</td>\n",
       "      <td>C</td>\n",
       "      <td>Houston Rockets</td>\n",
       "      <td>22.359364</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255</th>\n",
       "      <td>Carmelo Anthony</td>\n",
       "      <td>SF</td>\n",
       "      <td>New York Knicks</td>\n",
       "      <td>22.875000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>LeBron James</td>\n",
       "      <td>SF</td>\n",
       "      <td>Cleveland Cavaliers</td>\n",
       "      <td>22.970500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>Joe Johnson</td>\n",
       "      <td>SF</td>\n",
       "      <td>Brooklyn Nets</td>\n",
       "      <td>24.894863</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169</th>\n",
       "      <td>Kobe Bryant</td>\n",
       "      <td>SF</td>\n",
       "      <td>Los Angeles Lakers</td>\n",
       "      <td>25.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>69 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              PLAYER POSITION                 TEAM     SALARY\n",
       "368    DeMar DeRozan       SG      Toronto Raptors  10.050000\n",
       "298   Gerald Wallace       SF   Philadelphia 76ers  10.105855\n",
       "204        Luol Deng       SF           Miami Heat  10.151612\n",
       "144      Monta Ellis       SG       Indiana Pacers  10.300000\n",
       "95   Wilson Chandler       SF       Denver Nuggets  10.449438\n",
       "..               ...      ...                  ...        ...\n",
       "131    Dwight Howard        C      Houston Rockets  22.359364\n",
       "255  Carmelo Anthony       SF      New York Knicks  22.875000\n",
       "72      LeBron James       SF  Cleveland Cavaliers  22.970500\n",
       "29       Joe Johnson       SF        Brooklyn Nets  24.894863\n",
       "169      Kobe Bryant       SF   Los Angeles Lakers  25.000000\n",
       "\n",
       "[69 rows x 4 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba[nba['SALARY'] >10].sort_values('SALARY')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "How much did Stephen Curry make? For the answer, we have to access the row where the value of `PLAYER` is equal to `Stephen Curry`. That is placed a table consisting of just one line:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>121</th>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>PG</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>11.370786</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            PLAYER POSITION                   TEAM     SALARY\n",
       "121  Stephen Curry       PG  Golden State Warriors  11.370786"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba[nba['PLAYER'] == 'Stephen Curry']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Curry made just under $\\$11.4$ million dollars. That's a lot of money, but it's less than half the salary of LeBron James. You'll find that salary in the \"Top 5\" table earlier in this section, or you could find it replacing `'Stephen Curry'` by `'LeBron James'` in the line of code above.\n",
    "\n",
    "Thus for example you can get a DataFrame where the 'TEAM' is exactly equal to 'Golden State Warriors':"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>117</th>\n",
       "      <td>Klay Thompson</td>\n",
       "      <td>SG</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>15.501000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>118</th>\n",
       "      <td>Draymond Green</td>\n",
       "      <td>PF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>14.260870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119</th>\n",
       "      <td>Andrew Bogut</td>\n",
       "      <td>C</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>13.800000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>Andre Iguodala</td>\n",
       "      <td>SF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>11.710456</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>121</th>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>PG</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>11.370786</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122</th>\n",
       "      <td>Jason Thompson</td>\n",
       "      <td>PF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>7.008475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>123</th>\n",
       "      <td>Shaun Livingston</td>\n",
       "      <td>PG</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>5.543725</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>124</th>\n",
       "      <td>Harrison Barnes</td>\n",
       "      <td>SF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>3.873398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>125</th>\n",
       "      <td>Marreese Speights</td>\n",
       "      <td>C</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>3.815000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>126</th>\n",
       "      <td>Leandro Barbosa</td>\n",
       "      <td>SG</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>2.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>127</th>\n",
       "      <td>Festus Ezeli</td>\n",
       "      <td>C</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>2.008748</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>128</th>\n",
       "      <td>Brandon Rush</td>\n",
       "      <td>SF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>1.270964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>129</th>\n",
       "      <td>Kevon Looney</td>\n",
       "      <td>SF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>1.131960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>Anderson Varejao</td>\n",
       "      <td>PF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>0.289755</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                PLAYER POSITION                   TEAM     SALARY\n",
       "117      Klay Thompson       SG  Golden State Warriors  15.501000\n",
       "118     Draymond Green       PF  Golden State Warriors  14.260870\n",
       "119       Andrew Bogut        C  Golden State Warriors  13.800000\n",
       "120     Andre Iguodala       SF  Golden State Warriors  11.710456\n",
       "121      Stephen Curry       PG  Golden State Warriors  11.370786\n",
       "122     Jason Thompson       PF  Golden State Warriors   7.008475\n",
       "123   Shaun Livingston       PG  Golden State Warriors   5.543725\n",
       "124    Harrison Barnes       SF  Golden State Warriors   3.873398\n",
       "125  Marreese Speights        C  Golden State Warriors   3.815000\n",
       "126    Leandro Barbosa       SG  Golden State Warriors   2.500000\n",
       "127       Festus Ezeli        C  Golden State Warriors   2.008748\n",
       "128       Brandon Rush       SF  Golden State Warriors   1.270964\n",
       "129       Kevon Looney       SF  Golden State Warriors   1.131960\n",
       "130   Anderson Varejao       PF  Golden State Warriors   0.289755"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba[nba['TEAM'] == 'Golden State Warriors']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This portion of the table is already sorted by salary, because the original table listed players sorted by salary within the same team. By not using `.head()` at the end of the line all rows are shown, not just the first 10."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Multiple Features\n",
    "You can access rows that have multiple specified features, by using the boolean `&` operator. For example, here is a way to extract all the Point Guards whose salaries were over $\\$15$ million."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>Derrick Rose</td>\n",
       "      <td>PG</td>\n",
       "      <td>Chicago Bulls</td>\n",
       "      <td>20.093064</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>PG</td>\n",
       "      <td>Cleveland Cavaliers</td>\n",
       "      <td>16.407501</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>156</th>\n",
       "      <td>Chris Paul</td>\n",
       "      <td>PG</td>\n",
       "      <td>Los Angeles Clippers</td>\n",
       "      <td>21.468695</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>269</th>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>PG</td>\n",
       "      <td>Oklahoma City Thunder</td>\n",
       "      <td>16.744218</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>400</th>\n",
       "      <td>John Wall</td>\n",
       "      <td>PG</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>15.851950</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                PLAYER POSITION                   TEAM     SALARY\n",
       "60        Derrick Rose       PG          Chicago Bulls  20.093064\n",
       "74        Kyrie Irving       PG    Cleveland Cavaliers  16.407501\n",
       "156         Chris Paul       PG   Los Angeles Clippers  21.468695\n",
       "269  Russell Westbrook       PG  Oklahoma City Thunder  16.744218\n",
       "400          John Wall       PG     Washington Wizards  15.851950"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba[(nba['POSITION'] == 'PG') & (nba['SALARY'] > 15)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### General Form\n",
    "By now you will have realized that the general way to create a new df by selecting rows with a given feature is to use `&` or `OR` with the appropriate condition:\n",
    "\n",
    "`df[df['column_label_string'] condition(<, >, ==, =>, etc) criteria]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>144</th>\n",
       "      <td>Monta Ellis</td>\n",
       "      <td>SG</td>\n",
       "      <td>Indiana Pacers</td>\n",
       "      <td>10.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204</th>\n",
       "      <td>Luol Deng</td>\n",
       "      <td>SF</td>\n",
       "      <td>Miami Heat</td>\n",
       "      <td>10.151612</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>298</th>\n",
       "      <td>Gerald Wallace</td>\n",
       "      <td>SF</td>\n",
       "      <td>Philadelphia 76ers</td>\n",
       "      <td>10.105855</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>356</th>\n",
       "      <td>Danny Green</td>\n",
       "      <td>SG</td>\n",
       "      <td>San Antonio Spurs</td>\n",
       "      <td>10.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>368</th>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>SG</td>\n",
       "      <td>Toronto Raptors</td>\n",
       "      <td>10.050000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             PLAYER POSITION                TEAM     SALARY\n",
       "144     Monta Ellis       SG      Indiana Pacers  10.300000\n",
       "204       Luol Deng       SF          Miami Heat  10.151612\n",
       "298  Gerald Wallace       SF  Philadelphia 76ers  10.105855\n",
       "356     Danny Green       SG   San Antonio Spurs  10.000000\n",
       "368   DeMar DeRozan       SG     Toronto Raptors  10.050000"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba[(nba['SALARY'] >= 10) & (nba['SALARY'] <=10.3)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If we specify a condition that isn't satisfied by any row, we get a table with column labels but no rows."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [PLAYER, POSITION, TEAM, SALARY]\n",
       "Index: []"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba[nba['PLAYER'] == 'Barack Obama']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We end the section with a series of examples. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The use of `are.containing` can help save some typing. For example, you can just specify `Warriors` instead of `Golden State Warriors`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>117</th>\n",
       "      <td>Klay Thompson</td>\n",
       "      <td>SG</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>15.501000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>118</th>\n",
       "      <td>Draymond Green</td>\n",
       "      <td>PF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>14.260870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119</th>\n",
       "      <td>Andrew Bogut</td>\n",
       "      <td>C</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>13.800000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>Andre Iguodala</td>\n",
       "      <td>SF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>11.710456</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>121</th>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>PG</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>11.370786</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122</th>\n",
       "      <td>Jason Thompson</td>\n",
       "      <td>PF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>7.008475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>123</th>\n",
       "      <td>Shaun Livingston</td>\n",
       "      <td>PG</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>5.543725</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>124</th>\n",
       "      <td>Harrison Barnes</td>\n",
       "      <td>SF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>3.873398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>125</th>\n",
       "      <td>Marreese Speights</td>\n",
       "      <td>C</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>3.815000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>126</th>\n",
       "      <td>Leandro Barbosa</td>\n",
       "      <td>SG</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>2.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>127</th>\n",
       "      <td>Festus Ezeli</td>\n",
       "      <td>C</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>2.008748</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>128</th>\n",
       "      <td>Brandon Rush</td>\n",
       "      <td>SF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>1.270964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>129</th>\n",
       "      <td>Kevon Looney</td>\n",
       "      <td>SF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>1.131960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>Anderson Varejao</td>\n",
       "      <td>PF</td>\n",
       "      <td>Golden State Warriors</td>\n",
       "      <td>0.289755</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                PLAYER POSITION                   TEAM     SALARY\n",
       "117      Klay Thompson       SG  Golden State Warriors  15.501000\n",
       "118     Draymond Green       PF  Golden State Warriors  14.260870\n",
       "119       Andrew Bogut        C  Golden State Warriors  13.800000\n",
       "120     Andre Iguodala       SF  Golden State Warriors  11.710456\n",
       "121      Stephen Curry       PG  Golden State Warriors  11.370786\n",
       "122     Jason Thompson       PF  Golden State Warriors   7.008475\n",
       "123   Shaun Livingston       PG  Golden State Warriors   5.543725\n",
       "124    Harrison Barnes       SF  Golden State Warriors   3.873398\n",
       "125  Marreese Speights        C  Golden State Warriors   3.815000\n",
       "126    Leandro Barbosa       SG  Golden State Warriors   2.500000\n",
       "127       Festus Ezeli        C  Golden State Warriors   2.008748\n",
       "128       Brandon Rush       SF  Golden State Warriors   1.270964\n",
       "129       Kevon Looney       SF  Golden State Warriors   1.131960\n",
       "130   Anderson Varejao       PF  Golden State Warriors   0.289755"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba[nba['TEAM'].str.contains('Warriors')]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can extract data for all the guards, both Point Guards and Shooting Guards:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Jeff Teague</td>\n",
       "      <td>PG</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>8.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Kyle Korver</td>\n",
       "      <td>SG</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>5.746479</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Dennis Schroder</td>\n",
       "      <td>PG</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>1.763400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Tim Hardaway Jr.</td>\n",
       "      <td>SG</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>1.304520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Jason Richardson</td>\n",
       "      <td>SG</td>\n",
       "      <td>Atlanta Hawks</td>\n",
       "      <td>0.947276</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>409</th>\n",
       "      <td>Alan Anderson</td>\n",
       "      <td>SG</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>411</th>\n",
       "      <td>Ramon Sessions</td>\n",
       "      <td>PG</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>2.170465</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>412</th>\n",
       "      <td>Gary Neal</td>\n",
       "      <td>PG</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>2.139000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>415</th>\n",
       "      <td>Garrett Temple</td>\n",
       "      <td>SG</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>1.100602</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>416</th>\n",
       "      <td>Jarell Eddie</td>\n",
       "      <td>SG</td>\n",
       "      <td>Washington Wizards</td>\n",
       "      <td>0.561716</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>181 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               PLAYER POSITION                TEAM    SALARY\n",
       "3         Jeff Teague       PG       Atlanta Hawks  8.000000\n",
       "4         Kyle Korver       SG       Atlanta Hawks  5.746479\n",
       "8     Dennis Schroder       PG       Atlanta Hawks  1.763400\n",
       "9    Tim Hardaway Jr.       SG       Atlanta Hawks  1.304520\n",
       "11   Jason Richardson       SG       Atlanta Hawks  0.947276\n",
       "..                ...      ...                 ...       ...\n",
       "409     Alan Anderson       SG  Washington Wizards  4.000000\n",
       "411    Ramon Sessions       PG  Washington Wizards  2.170465\n",
       "412         Gary Neal       PG  Washington Wizards  2.139000\n",
       "415    Garrett Temple       SG  Washington Wizards  1.100602\n",
       "416      Jarell Eddie       SG  Washington Wizards  0.561716\n",
       "\n",
       "[181 rows x 4 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nba[nba['POSITION'].str.contains('G')]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can get all the players who were not Cleveland Cavaliers and had a salary of no less than $\\$20$ million:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "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>PLAYER</th>\n",
       "      <th>POSITION</th>\n",
       "      <th>TEAM</th>\n",
       "      <th>SALARY</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>Joe Johnson</td>\n",
       "      <td>SF</td>\n",
       "      <td>Brooklyn Nets</td>\n",
       "      <td>24.894863</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>Derrick Rose</td>\n",
       "      <td>PG</td>\n",
       "      <td>Chicago Bulls</td>\n",
       "      <td>20.093064</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>Dwight Howard</td>\n",
       "      <td>C</td>\n",
       "      <td>Houston Rockets</td>\n",
       "      <td>22.359364</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>156</th>\n",
       "      <td>Chris Paul</td>\n",
       "      <td>PG</td>\n",
       "      <td>Los Angeles Clippers</td>\n",
       "      <td>21.468695</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169</th>\n",
       "      <td>Kobe Bryant</td>\n",
       "      <td>SF</td>\n",
       "      <td>Los Angeles Lakers</td>\n",
       "      <td>25.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>201</th>\n",
       "      <td>Chris Bosh</td>\n",
       "      <td>PF</td>\n",
       "      <td>Miami Heat</td>\n",
       "      <td>22.192730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255</th>\n",
       "      <td>Carmelo Anthony</td>\n",
       "      <td>SF</td>\n",
       "      <td>New York Knicks</td>\n",
       "      <td>22.875000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>268</th>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>SF</td>\n",
       "      <td>Oklahoma City Thunder</td>\n",
       "      <td>20.158622</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              PLAYER POSITION                   TEAM     SALARY\n",
       "29       Joe Johnson       SF          Brooklyn Nets  24.894863\n",
       "60      Derrick Rose       PG          Chicago Bulls  20.093064\n",
       "131    Dwight Howard        C        Houston Rockets  22.359364\n",
       "156       Chris Paul       PG   Los Angeles Clippers  21.468695\n",
       "169      Kobe Bryant       SF     Los Angeles Lakers  25.000000\n",
       "201       Chris Bosh       PF             Miami Heat  22.192730\n",
       "255  Carmelo Anthony       SF        New York Knicks  22.875000\n",
       "268     Kevin Durant       SF  Oklahoma City Thunder  20.158622"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "other_than_Cavs = nba[nba['TEAM'] != 'Cleveland Cavaliers']\n",
    "other_than_Cavs[other_than_Cavs['SALARY']  > 20]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The same table can be created in many ways. Here is another, and no doubt you can think of more."
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "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.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
