{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e3131552-f8fe-4ec4-b41b-5606274d44d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (4, 3)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>state</th><th>year</th><th>pop</th></tr><tr><td>str</td><td>i64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;Ohio&quot;</td><td>2000</td><td>1.5</td></tr><tr><td>&quot;Ohio&quot;</td><td>2001</td><td>1.7</td></tr><tr><td>&quot;Ohio&quot;</td><td>2002</td><td>3.6</td></tr><tr><td>&quot;Nevada&quot;</td><td>2001</td><td>2.4</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (4, 3)\n",
       "┌────────┬──────┬─────┐\n",
       "│ state  ┆ year ┆ pop │\n",
       "│ ---    ┆ ---  ┆ --- │\n",
       "│ str    ┆ i64  ┆ f64 │\n",
       "╞════════╪══════╪═════╡\n",
       "│ Ohio   ┆ 2000 ┆ 1.5 │\n",
       "│ Ohio   ┆ 2001 ┆ 1.7 │\n",
       "│ Ohio   ┆ 2002 ┆ 3.6 │\n",
       "│ Nevada ┆ 2001 ┆ 2.4 │\n",
       "└────────┴──────┴─────┘"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import polars as pl\n",
    "\n",
    "df = pl.DataFrame({'state': ['Ohio', 'Ohio', 'Ohio', 'Nevada'],\n",
    "                'year': [2000, 2001, 2002, 2001],\n",
    "                'pop': [1.5, 1.7, 3.6, 2.4]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "03eb5f7d-7e84-4607-9f31-9c6490165eaf",
   "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>state</th>\n",
       "      <th>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2002</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Nevada</td>\n",
       "      <td>2001</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    state  year  pop\n",
       "0    Ohio  2000  1.5\n",
       "1    Ohio  2001  1.7\n",
       "2    Ohio  2002  3.6\n",
       "3  Nevada  2001  2.4"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "dfa = pd.DataFrame({'state': ['Ohio', 'Ohio', 'Ohio', 'Nevada'],\n",
    "                  'year': [2000, 2001, 2002, 2001],\n",
    "                  'pop': [1.5, 1.7, 3.6, 2.4]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "0ee87cc5-feb2-413d-a012-49e1e898c792",
   "metadata": {
    "scrolled": true
   },
   "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>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>state</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2002</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Nevada</th>\n",
       "      <td>2001</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        year  pop\n",
       "state            \n",
       "Ohio    2000  1.5\n",
       "Ohio    2001  1.7\n",
       "Ohio    2002  3.6\n",
       "Nevada  2001  2.4"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfi = dfa.set_index('state')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "593fa040-0718-4af7-8696-679c939e19d1",
   "metadata": {},
   "source": [
    "#### Indexing"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "90a5166f-265d-436a-899e-59ae9321761a",
   "metadata": {},
   "source": [
    "##### polars"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4f2b3ee5-dac9-4a51-9524-d39973ed3b36",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (1, 3)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>state</th><th>year</th><th>pop</th></tr><tr><td>str</td><td>i64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;Ohio&quot;</td><td>2000</td><td>1.5</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (1, 3)\n",
       "┌───────┬──────┬─────┐\n",
       "│ state ┆ year ┆ pop │\n",
       "│ ---   ┆ ---  ┆ --- │\n",
       "│ str   ┆ i64  ┆ f64 │\n",
       "╞═══════╪══════╪═════╡\n",
       "│ Ohio  ┆ 2000 ┆ 1.5 │\n",
       "└───────┴──────┴─────┘"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7e14d95a-2e44-4671-9e2a-33552c8a305b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (1, 3)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>state</th><th>year</th><th>pop</th></tr><tr><td>str</td><td>i64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;Ohio&quot;</td><td>2000</td><td>1.5</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (1, 3)\n",
       "┌───────┬──────┬─────┐\n",
       "│ state ┆ year ┆ pop │\n",
       "│ ---   ┆ ---  ┆ --- │\n",
       "│ str   ┆ i64  ┆ f64 │\n",
       "╞═══════╪══════╪═════╡\n",
       "│ Ohio  ┆ 2000 ┆ 1.5 │\n",
       "└───────┴──────┴─────┘"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[0:1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4c71b9cc-09e5-4b9b-8f57-0c2c10632081",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (2, 3)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>state</th><th>year</th><th>pop</th></tr><tr><td>str</td><td>i64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;Ohio&quot;</td><td>2000</td><td>1.5</td></tr><tr><td>&quot;Ohio&quot;</td><td>2001</td><td>1.7</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (2, 3)\n",
       "┌───────┬──────┬─────┐\n",
       "│ state ┆ year ┆ pop │\n",
       "│ ---   ┆ ---  ┆ --- │\n",
       "│ str   ┆ i64  ┆ f64 │\n",
       "╞═══════╪══════╪═════╡\n",
       "│ Ohio  ┆ 2000 ┆ 1.5 │\n",
       "│ Ohio  ┆ 2001 ┆ 1.7 │\n",
       "└───────┴──────┴─────┘"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[0:2]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4d122383-e194-4e9f-a8a6-86b7dd00413a",
   "metadata": {},
   "source": [
    "##### pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "d2ff7e2b-c2cb-45f2-aee7-6bf65a4b5b75",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "0",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mKeyError\u001b[39m                                  Traceback (most recent call last)",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/pandas/core/indexes/base.py:3812\u001b[39m, in \u001b[36mIndex.get_loc\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m   3811\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m3812\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_engine\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcasted_key\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   3813\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n",
      "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/index.pyx:167\u001b[39m, in \u001b[36mpandas._libs.index.IndexEngine.get_loc\u001b[39m\u001b[34m()\u001b[39m\n",
      "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/index.pyx:196\u001b[39m, in \u001b[36mpandas._libs.index.IndexEngine.get_loc\u001b[39m\u001b[34m()\u001b[39m\n",
      "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/hashtable_class_helper.pxi:7088\u001b[39m, in \u001b[36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[39m\u001b[34m()\u001b[39m\n",
      "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/hashtable_class_helper.pxi:7096\u001b[39m, in \u001b[36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[39m\u001b[34m()\u001b[39m\n",
      "\u001b[31mKeyError\u001b[39m: 0",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[31mKeyError\u001b[39m                                  Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[10]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mdfa\u001b[49m\u001b[43m[\u001b[49m\u001b[32;43m0\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/pandas/core/frame.py:4113\u001b[39m, in \u001b[36mDataFrame.__getitem__\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m   4111\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.columns.nlevels > \u001b[32m1\u001b[39m:\n\u001b[32m   4112\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._getitem_multilevel(key)\n\u001b[32m-> \u001b[39m\u001b[32m4113\u001b[39m indexer = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mcolumns\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   4114\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m is_integer(indexer):\n\u001b[32m   4115\u001b[39m     indexer = [indexer]\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/pandas/core/indexes/base.py:3819\u001b[39m, in \u001b[36mIndex.get_loc\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m   3814\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(casted_key, \u001b[38;5;28mslice\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m (\n\u001b[32m   3815\u001b[39m         \u001b[38;5;28misinstance\u001b[39m(casted_key, abc.Iterable)\n\u001b[32m   3816\u001b[39m         \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28many\u001b[39m(\u001b[38;5;28misinstance\u001b[39m(x, \u001b[38;5;28mslice\u001b[39m) \u001b[38;5;28;01mfor\u001b[39;00m x \u001b[38;5;129;01min\u001b[39;00m casted_key)\n\u001b[32m   3817\u001b[39m     ):\n\u001b[32m   3818\u001b[39m         \u001b[38;5;28;01mraise\u001b[39;00m InvalidIndexError(key)\n\u001b[32m-> \u001b[39m\u001b[32m3819\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01merr\u001b[39;00m\n\u001b[32m   3820\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[32m   3821\u001b[39m     \u001b[38;5;66;03m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[32m   3822\u001b[39m     \u001b[38;5;66;03m#  InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[32m   3823\u001b[39m     \u001b[38;5;66;03m#  the TypeError.\u001b[39;00m\n\u001b[32m   3824\u001b[39m     \u001b[38;5;28mself\u001b[39m._check_indexing_error(key)\n",
      "\u001b[31mKeyError\u001b[39m: 0"
     ]
    }
   ],
   "source": [
    "dfa[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "221bd8a2-1705-4549-a9c0-89a8ce2b9aee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "state    Ohio\n",
       "year     2000\n",
       "pop       1.5\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.loc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "fe2cc9cb-2074-4dc5-96e6-9e3d978c5ef7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "state    Ohio\n",
       "year     2000\n",
       "pop       1.5\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "5d481cbc-c8fb-4059-86fe-c38a844fa420",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(dfa.iloc[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "3aa3c167-43fa-4aba-82ef-81434bdb7f78",
   "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>state</th>\n",
       "      <th>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  state  year  pop\n",
       "0  Ohio  2000  1.5\n",
       "1  Ohio  2001  1.7"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "31c149e9-4477-42ad-add3-23d5cf06290e",
   "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>state</th>\n",
       "      <th>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  state  year  pop\n",
       "0  Ohio  2000  1.5\n",
       "1  Ohio  2001  1.7"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.iloc[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "685d5fae-87ca-4eda-a6ba-100566b50700",
   "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>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>state</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2002</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Nevada</th>\n",
       "      <td>2001</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        year  pop\n",
       "state            \n",
       "Ohio    2000  1.5\n",
       "Ohio    2001  1.7\n",
       "Ohio    2002  3.6\n",
       "Nevada  2001  2.4"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfi = dfa.set_index('state')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "1d8a847b-ff37-45d7-8034-9e883426c331",
   "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>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>state</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2002</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Nevada</th>\n",
       "      <td>2001</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        year  pop\n",
       "state            \n",
       "Ohio    2000  1.5\n",
       "Ohio    2001  1.7\n",
       "Ohio    2002  3.6\n",
       "Nevada  2001  2.4"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "b914e572-a0d0-4953-899e-cad1a8fc49aa",
   "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>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>state</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2002</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       year  pop\n",
       "state           \n",
       "Ohio   2000  1.5\n",
       "Ohio   2001  1.7\n",
       "Ohio   2002  3.6"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfi.loc['Ohio']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "3b1d9e83-78d9-45be-a455-3599b42769db",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "year    2001.0\n",
       "pop        2.4\n",
       "Name: Nevada, dtype: float64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfi.loc['Nevada']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "92b02bef-e2fc-4dc0-be38-05bc2fa11b28",
   "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>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>state</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       year  pop\n",
       "state           \n",
       "Ohio   2000  1.5\n",
       "Ohio   2001  1.7"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfi.iloc[:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "9a3d887d-12f7-4dd4-a8c8-26110f7b73fc",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'Texas'",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mKeyError\u001b[39m                                  Traceback (most recent call last)",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/pandas/core/indexes/base.py:3812\u001b[39m, in \u001b[36mIndex.get_loc\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m   3811\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m3812\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_engine\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcasted_key\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   3813\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n",
      "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/index.pyx:167\u001b[39m, in \u001b[36mpandas._libs.index.IndexEngine.get_loc\u001b[39m\u001b[34m()\u001b[39m\n",
      "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/index.pyx:191\u001b[39m, in \u001b[36mpandas._libs.index.IndexEngine.get_loc\u001b[39m\u001b[34m()\u001b[39m\n",
      "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/index.pyx:234\u001b[39m, in \u001b[36mpandas._libs.index.IndexEngine._get_loc_duplicates\u001b[39m\u001b[34m()\u001b[39m\n",
      "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/index.pyx:242\u001b[39m, in \u001b[36mpandas._libs.index.IndexEngine._maybe_get_bool_indexer\u001b[39m\u001b[34m()\u001b[39m\n",
      "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/index.pyx:134\u001b[39m, in \u001b[36mpandas._libs.index._unpack_bool_indexer\u001b[39m\u001b[34m()\u001b[39m\n",
      "\u001b[31mKeyError\u001b[39m: 'Texas'",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[31mKeyError\u001b[39m                                  Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[20]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mdfi\u001b[49m\u001b[43m.\u001b[49m\u001b[43mloc\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mTexas\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/pandas/core/indexing.py:1192\u001b[39m, in \u001b[36m_LocationIndexer.__getitem__\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m   1190\u001b[39m maybe_callable = com.apply_if_callable(key, \u001b[38;5;28mself\u001b[39m.obj)\n\u001b[32m   1191\u001b[39m maybe_callable = \u001b[38;5;28mself\u001b[39m._check_deprecated_callable_usage(key, maybe_callable)\n\u001b[32m-> \u001b[39m\u001b[32m1192\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_getitem_axis\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmaybe_callable\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[43m=\u001b[49m\u001b[43maxis\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/pandas/core/indexing.py:1432\u001b[39m, in \u001b[36m_LocIndexer._getitem_axis\u001b[39m\u001b[34m(self, key, axis)\u001b[39m\n\u001b[32m   1430\u001b[39m \u001b[38;5;66;03m# fall thru to straight lookup\u001b[39;00m\n\u001b[32m   1431\u001b[39m \u001b[38;5;28mself\u001b[39m._validate_key(key, axis)\n\u001b[32m-> \u001b[39m\u001b[32m1432\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_get_label\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[43m=\u001b[49m\u001b[43maxis\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/pandas/core/indexing.py:1382\u001b[39m, in \u001b[36m_LocIndexer._get_label\u001b[39m\u001b[34m(self, label, axis)\u001b[39m\n\u001b[32m   1380\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m_get_label\u001b[39m(\u001b[38;5;28mself\u001b[39m, label, axis: AxisInt):\n\u001b[32m   1381\u001b[39m     \u001b[38;5;66;03m# GH#5567 this will fail if the label is not present in the axis.\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m1382\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mobj\u001b[49m\u001b[43m.\u001b[49m\u001b[43mxs\u001b[49m\u001b[43m(\u001b[49m\u001b[43mlabel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[43m=\u001b[49m\u001b[43maxis\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/pandas/core/generic.py:4323\u001b[39m, in \u001b[36mNDFrame.xs\u001b[39m\u001b[34m(self, key, axis, level, drop_level)\u001b[39m\n\u001b[32m   4321\u001b[39m             new_index = index[loc]\n\u001b[32m   4322\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m4323\u001b[39m     loc = \u001b[43mindex\u001b[49m\u001b[43m.\u001b[49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m   4325\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(loc, np.ndarray):\n\u001b[32m   4326\u001b[39m         \u001b[38;5;28;01mif\u001b[39;00m loc.dtype == np.bool_:\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/pandas/core/indexes/base.py:3819\u001b[39m, in \u001b[36mIndex.get_loc\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m   3814\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(casted_key, \u001b[38;5;28mslice\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m (\n\u001b[32m   3815\u001b[39m         \u001b[38;5;28misinstance\u001b[39m(casted_key, abc.Iterable)\n\u001b[32m   3816\u001b[39m         \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28many\u001b[39m(\u001b[38;5;28misinstance\u001b[39m(x, \u001b[38;5;28mslice\u001b[39m) \u001b[38;5;28;01mfor\u001b[39;00m x \u001b[38;5;129;01min\u001b[39;00m casted_key)\n\u001b[32m   3817\u001b[39m     ):\n\u001b[32m   3818\u001b[39m         \u001b[38;5;28;01mraise\u001b[39;00m InvalidIndexError(key)\n\u001b[32m-> \u001b[39m\u001b[32m3819\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01merr\u001b[39;00m\n\u001b[32m   3820\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[32m   3821\u001b[39m     \u001b[38;5;66;03m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[32m   3822\u001b[39m     \u001b[38;5;66;03m#  InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[32m   3823\u001b[39m     \u001b[38;5;66;03m#  the TypeError.\u001b[39;00m\n\u001b[32m   3824\u001b[39m     \u001b[38;5;28mself\u001b[39m._check_indexing_error(key)\n",
      "\u001b[31mKeyError\u001b[39m: 'Texas'"
     ]
    }
   ],
   "source": [
    "dfi.loc['Texas']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "d50a695d-4f10-4398-9449-f3ce6a73679a",
   "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>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>state</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2002</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Nevada</th>\n",
       "      <td>2001</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        year  pop\n",
       "state            \n",
       "Ohio    2000  1.5\n",
       "Ohio    2001  1.7\n",
       "Ohio    2002  3.6\n",
       "Nevada  2001  2.4"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfi.loc['Ohio':'Nevada'] # inclusive!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "a9f277e5-9a47-487f-8eb4-2400819ac200",
   "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>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>state</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       year  pop\n",
       "state           \n",
       "Ohio   2000  1.5\n",
       "Ohio   2001  1.7"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfi.iloc[:2] # exclusive"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c9ae761b-e170-440c-91a6-2e725a152775",
   "metadata": {},
   "source": [
    "#### Filtering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "0cf67f73-a0f3-4a3f-9240-6274c631b098",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (4,)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>pop</th></tr><tr><td>bool</td></tr></thead><tbody><tr><td>false</td></tr><tr><td>false</td></tr><tr><td>true</td></tr><tr><td>true</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (4,)\n",
       "Series: 'pop' [bool]\n",
       "[\n",
       "\tfalse\n",
       "\tfalse\n",
       "\ttrue\n",
       "\ttrue\n",
       "]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['pop'] > 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "59ef321f-312e-4307-a380-10b41a2f7553",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "expected 3 values when selecting columns by boolean mask, got 4",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mTypeError\u001b[39m                                 Traceback (most recent call last)",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/_utils/getitem.py:167\u001b[39m, in \u001b[36mget_df_item_by_key\u001b[39m\u001b[34m(df, key)\u001b[39m\n\u001b[32m    166\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m167\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_select_rows\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m  \u001b[38;5;66;03m# type: ignore[arg-type]\u001b[39;00m\n\u001b[32m    168\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/_utils/getitem.py:319\u001b[39m, in \u001b[36m_select_rows\u001b[39m\u001b[34m(df, key)\u001b[39m\n\u001b[32m    318\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(key, pl.Series):\n\u001b[32m--> \u001b[39m\u001b[32m319\u001b[39m     indices = \u001b[43m_convert_series_to_indices\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdf\u001b[49m\u001b[43m.\u001b[49m\u001b[43mheight\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    320\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m _select_rows_by_index(df, indices)\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/_utils/getitem.py:360\u001b[39m, in \u001b[36m_convert_series_to_indices\u001b[39m\u001b[34m(s, size)\u001b[39m\n\u001b[32m    359\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m s.dtype == Boolean:\n\u001b[32m--> \u001b[39m\u001b[32m360\u001b[39m     \u001b[43m_raise_on_boolean_mask\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    361\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/_utils/getitem.py:457\u001b[39m, in \u001b[36m_raise_on_boolean_mask\u001b[39m\u001b[34m()\u001b[39m\n\u001b[32m    453\u001b[39m msg = (\n\u001b[32m    454\u001b[39m     \u001b[33m\"\u001b[39m\u001b[33mselecting rows by passing a boolean mask to `__getitem__` is not supported\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m    455\u001b[39m     \u001b[33m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33mHint: Use the `filter` method instead.\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m    456\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m457\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(msg)\n",
      "\u001b[31mTypeError\u001b[39m: selecting rows by passing a boolean mask to `__getitem__` is not supported\n\nHint: Use the `filter` method instead.",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[31mValueError\u001b[39m                                Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[24]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mdf\u001b[49m\u001b[43m[\u001b[49m\u001b[43mdf\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mpop\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[43m>\u001b[49m\u001b[43m \u001b[49m\u001b[32;43m2\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/dataframe/frame.py:1403\u001b[39m, in \u001b[36mDataFrame.__getitem__\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m   1266\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__getitem__\u001b[39m(\n\u001b[32m   1267\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   1268\u001b[39m     key: (\n\u001b[32m   (...)\u001b[39m\u001b[32m   1277\u001b[39m     ),\n\u001b[32m   1278\u001b[39m ) -> DataFrame | Series | Any:\n\u001b[32m   1279\u001b[39m \u001b[38;5;250m    \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m   1280\u001b[39m \u001b[33;03m    Get part of the DataFrame as a new DataFrame, Series, or scalar.\u001b[39;00m\n\u001b[32m   1281\u001b[39m \n\u001b[32m   (...)\u001b[39m\u001b[32m   1401\u001b[39m \u001b[33;03m    └─────┴─────┴─────┘\u001b[39;00m\n\u001b[32m   1402\u001b[39m \u001b[33;03m    \"\"\"\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m1403\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mget_df_item_by_key\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/_utils/getitem.py:169\u001b[39m, in \u001b[36mget_df_item_by_key\u001b[39m\u001b[34m(df, key)\u001b[39m\n\u001b[32m    167\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m _select_rows(df, key)  \u001b[38;5;66;03m# type: ignore[arg-type]\u001b[39;00m\n\u001b[32m    168\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m169\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_select_columns\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/_utils/getitem.py:231\u001b[39m, in \u001b[36m_select_columns\u001b[39m\u001b[34m(df, key)\u001b[39m\n\u001b[32m    229\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m _select_columns_by_index(df, key)\n\u001b[32m    230\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m dtype == Boolean:\n\u001b[32m--> \u001b[39m\u001b[32m231\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_select_columns_by_mask\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m    232\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m    233\u001b[39m     msg = \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mcannot select columns using Series of type \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mdtype\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/_utils/getitem.py:277\u001b[39m, in \u001b[36m_select_columns_by_mask\u001b[39m\u001b[34m(df, key)\u001b[39m\n\u001b[32m    275\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(key) != df.width:\n\u001b[32m    276\u001b[39m     msg = \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mexpected \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mdf.width\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m values when selecting columns by boolean mask, got \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlen\u001b[39m(key)\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m--> \u001b[39m\u001b[32m277\u001b[39m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(msg)\n\u001b[32m    279\u001b[39m indices = (i \u001b[38;5;28;01mfor\u001b[39;00m i, val \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(key) \u001b[38;5;28;01mif\u001b[39;00m val)\n\u001b[32m    280\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m _select_columns_by_index(df, indices)\n",
      "\u001b[31mValueError\u001b[39m: expected 3 values when selecting columns by boolean mask, got 4"
     ]
    }
   ],
   "source": [
    "df[df['pop'] > 2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "cb993d3b-e0b3-4156-97f3-7e31eb3bbe47",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (2, 3)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>state</th><th>year</th><th>pop</th></tr><tr><td>str</td><td>i64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;Ohio&quot;</td><td>2002</td><td>3.6</td></tr><tr><td>&quot;Nevada&quot;</td><td>2001</td><td>2.4</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (2, 3)\n",
       "┌────────┬──────┬─────┐\n",
       "│ state  ┆ year ┆ pop │\n",
       "│ ---    ┆ ---  ┆ --- │\n",
       "│ str    ┆ i64  ┆ f64 │\n",
       "╞════════╪══════╪═════╡\n",
       "│ Ohio   ┆ 2002 ┆ 3.6 │\n",
       "│ Nevada ┆ 2001 ┆ 2.4 │\n",
       "└────────┴──────┴─────┘"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.filter(pl.col('pop') > 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "9082b190-8bd1-436c-9fc3-d2f0cbba03d2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    False\n",
       "1    False\n",
       "2     True\n",
       "3     True\n",
       "Name: pop, dtype: bool"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa['pop'] > 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "491388c2-75a7-4fb1-be51-69d28eac7cea",
   "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>state</th>\n",
       "      <th>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2002</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Nevada</td>\n",
       "      <td>2001</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    state  year  pop\n",
       "2    Ohio  2002  3.6\n",
       "3  Nevada  2001  2.4"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa[dfa['pop'] > 2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "db4bd903-7e9e-4016-9779-cd8a6f5fb44b",
   "metadata": {
    "scrolled": true
   },
   "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>state</th>\n",
       "      <th>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2002</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Nevada</td>\n",
       "      <td>2001</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    state  year  pop\n",
       "2    Ohio  2002  3.6\n",
       "3  Nevada  2001  2.4"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.query('pop > 2')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "70d2408d-a125-40db-b8eb-9126abadc699",
   "metadata": {},
   "source": [
    "#### Sorting "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "07c9bbc8-d4fb-4e5d-bbff-b931d3161c64",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (4, 3)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>state</th><th>year</th><th>pop</th></tr><tr><td>str</td><td>i64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;Ohio&quot;</td><td>2000</td><td>1.5</td></tr><tr><td>&quot;Ohio&quot;</td><td>2001</td><td>1.7</td></tr><tr><td>&quot;Nevada&quot;</td><td>2001</td><td>2.4</td></tr><tr><td>&quot;Ohio&quot;</td><td>2002</td><td>3.6</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (4, 3)\n",
       "┌────────┬──────┬─────┐\n",
       "│ state  ┆ year ┆ pop │\n",
       "│ ---    ┆ ---  ┆ --- │\n",
       "│ str    ┆ i64  ┆ f64 │\n",
       "╞════════╪══════╪═════╡\n",
       "│ Ohio   ┆ 2000 ┆ 1.5 │\n",
       "│ Ohio   ┆ 2001 ┆ 1.7 │\n",
       "│ Nevada ┆ 2001 ┆ 2.4 │\n",
       "│ Ohio   ┆ 2002 ┆ 3.6 │\n",
       "└────────┴──────┴─────┘"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort('pop')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "cfb89459-16d2-4b1b-8c99-b6e6fc0f66a2",
   "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>state</th>\n",
       "      <th>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Nevada</td>\n",
       "      <td>2001</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>2002</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    state  year  pop\n",
       "0    Ohio  2000  1.5\n",
       "1    Ohio  2001  1.7\n",
       "3  Nevada  2001  2.4\n",
       "2    Ohio  2002  3.6"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.sort_values('pop')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "3db0ee27-29e2-4cba-8bb2-5883881bd1ad",
   "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>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>state</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Nevada</th>\n",
       "      <td>2001</td>\n",
       "      <td>2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2000</td>\n",
       "      <td>1.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2001</td>\n",
       "      <td>1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Ohio</th>\n",
       "      <td>2002</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        year  pop\n",
       "state            \n",
       "Nevada  2001  2.4\n",
       "Ohio    2000  1.5\n",
       "Ohio    2001  1.7\n",
       "Ohio    2002  3.6"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfi.sort_index()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2845da74-73ba-4776-965c-a34938662b06",
   "metadata": {},
   "source": [
    "#### Describe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "6f30c191-3c79-4056-9df0-e6a3b556e16c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (9, 4)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>statistic</th><th>state</th><th>year</th><th>pop</th></tr><tr><td>str</td><td>str</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;count&quot;</td><td>&quot;4&quot;</td><td>4.0</td><td>4.0</td></tr><tr><td>&quot;null_count&quot;</td><td>&quot;0&quot;</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;mean&quot;</td><td>null</td><td>2001.0</td><td>2.3</td></tr><tr><td>&quot;std&quot;</td><td>null</td><td>0.816497</td><td>0.948683</td></tr><tr><td>&quot;min&quot;</td><td>&quot;Nevada&quot;</td><td>2000.0</td><td>1.5</td></tr><tr><td>&quot;25%&quot;</td><td>null</td><td>2001.0</td><td>1.7</td></tr><tr><td>&quot;50%&quot;</td><td>null</td><td>2001.0</td><td>2.4</td></tr><tr><td>&quot;75%&quot;</td><td>null</td><td>2001.0</td><td>2.4</td></tr><tr><td>&quot;max&quot;</td><td>&quot;Ohio&quot;</td><td>2002.0</td><td>3.6</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (9, 4)\n",
       "┌────────────┬────────┬──────────┬──────────┐\n",
       "│ statistic  ┆ state  ┆ year     ┆ pop      │\n",
       "│ ---        ┆ ---    ┆ ---      ┆ ---      │\n",
       "│ str        ┆ str    ┆ f64      ┆ f64      │\n",
       "╞════════════╪════════╪══════════╪══════════╡\n",
       "│ count      ┆ 4      ┆ 4.0      ┆ 4.0      │\n",
       "│ null_count ┆ 0      ┆ 0.0      ┆ 0.0      │\n",
       "│ mean       ┆ null   ┆ 2001.0   ┆ 2.3      │\n",
       "│ std        ┆ null   ┆ 0.816497 ┆ 0.948683 │\n",
       "│ min        ┆ Nevada ┆ 2000.0   ┆ 1.5      │\n",
       "│ 25%        ┆ null   ┆ 2001.0   ┆ 1.7      │\n",
       "│ 50%        ┆ null   ┆ 2001.0   ┆ 2.4      │\n",
       "│ 75%        ┆ null   ┆ 2001.0   ┆ 2.4      │\n",
       "│ max        ┆ Ohio   ┆ 2002.0   ┆ 3.6      │\n",
       "└────────────┴────────┴──────────┴──────────┘"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "3c893ffd-da99-4c65-93d5-e1f245e715f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.describe()['state'][2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "43d7fe3f-5150-4bcf-acf8-997b9040aba1",
   "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>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>4.000000</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>2001.000000</td>\n",
       "      <td>2.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.816497</td>\n",
       "      <td>0.948683</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>2000.000000</td>\n",
       "      <td>1.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>2000.750000</td>\n",
       "      <td>1.650000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>2001.000000</td>\n",
       "      <td>2.050000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>2001.250000</td>\n",
       "      <td>2.700000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>2002.000000</td>\n",
       "      <td>3.600000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              year       pop\n",
       "count     4.000000  4.000000\n",
       "mean   2001.000000  2.300000\n",
       "std       0.816497  0.948683\n",
       "min    2000.000000  1.500000\n",
       "25%    2000.750000  1.650000\n",
       "50%    2001.000000  2.050000\n",
       "75%    2001.250000  2.700000\n",
       "max    2002.000000  3.600000"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "b8097412-9b62-47a3-a68d-703f745e63bc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count        4\n",
       "unique       2\n",
       "top       Ohio\n",
       "freq         3\n",
       "Name: state, dtype: object"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.state.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "bef580eb-4d69-4fbd-a320-8efa6a71c429",
   "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>state</th>\n",
       "      <th>year</th>\n",
       "      <th>pop</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>4</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>unique</th>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>top</th>\n",
       "      <td>Ohio</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>freq</th>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2001.000000</td>\n",
       "      <td>2.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>NaN</td>\n",
       "      <td>0.816497</td>\n",
       "      <td>0.948683</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>1.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2000.750000</td>\n",
       "      <td>1.650000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2001.000000</td>\n",
       "      <td>2.050000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2001.250000</td>\n",
       "      <td>2.700000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2002.000000</td>\n",
       "      <td>3.600000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       state         year       pop\n",
       "count      4     4.000000  4.000000\n",
       "unique     2          NaN       NaN\n",
       "top     Ohio          NaN       NaN\n",
       "freq       3          NaN       NaN\n",
       "mean     NaN  2001.000000  2.300000\n",
       "std      NaN     0.816497  0.948683\n",
       "min      NaN  2000.000000  1.500000\n",
       "25%      NaN  2000.750000  1.650000\n",
       "50%      NaN  2001.000000  2.050000\n",
       "75%      NaN  2001.250000  2.700000\n",
       "max      NaN  2002.000000  3.600000"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.describe(include='all')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d16a2e1-dfd9-453b-9cbd-f5cfd97d1d72",
   "metadata": {},
   "source": [
    "### Penguins Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "31877969-5fee-461b-8e7e-53ad854ed40f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (344, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>studyName</th><th>Sample Number</th><th>Species</th><th>Region</th><th>Island</th><th>Stage</th><th>Individual ID</th><th>Clutch Completion</th><th>Date Egg</th><th>Culmen Length (mm)</th><th>Culmen Depth (mm)</th><th>Flipper Length (mm)</th><th>Body Mass (g)</th><th>Sex</th><th>Delta 15 N (o/oo)</th><th>Delta 13 C (o/oo)</th><th>Comments</th></tr><tr><td>str</td><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>i64</td><td>i64</td><td>str</td><td>f64</td><td>f64</td><td>str</td></tr></thead><tbody><tr><td>&quot;PAL0708&quot;</td><td>1</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N1A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/11/07&quot;</td><td>39.1</td><td>18.7</td><td>181</td><td>3750</td><td>&quot;MALE&quot;</td><td>null</td><td>null</td><td>&quot;Not enough blood for isotopes.&quot;</td></tr><tr><td>&quot;PAL0708&quot;</td><td>2</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N1A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/11/07&quot;</td><td>39.5</td><td>17.4</td><td>186</td><td>3800</td><td>&quot;FEMALE&quot;</td><td>8.94956</td><td>-24.69454</td><td>null</td></tr><tr><td>&quot;PAL0708&quot;</td><td>3</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N2A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/16/07&quot;</td><td>40.3</td><td>18.0</td><td>195</td><td>3250</td><td>&quot;FEMALE&quot;</td><td>8.36821</td><td>-25.33302</td><td>null</td></tr><tr><td>&quot;PAL0708&quot;</td><td>4</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N2A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/16/07&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>&quot;Adult not sampled.&quot;</td></tr><tr><td>&quot;PAL0708&quot;</td><td>5</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N3A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/16/07&quot;</td><td>36.7</td><td>19.3</td><td>193</td><td>3450</td><td>&quot;FEMALE&quot;</td><td>8.76651</td><td>-25.32426</td><td>null</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;PAL0910&quot;</td><td>120</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N38A2&quot;</td><td>&quot;No&quot;</td><td>&quot;12/1/09&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>121</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N39A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>46.8</td><td>14.3</td><td>215</td><td>4850</td><td>&quot;FEMALE&quot;</td><td>8.41151</td><td>-26.13832</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>122</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N39A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>50.4</td><td>15.7</td><td>222</td><td>5750</td><td>&quot;MALE&quot;</td><td>8.30166</td><td>-26.04117</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>123</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N43A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>45.2</td><td>14.8</td><td>212</td><td>5200</td><td>&quot;FEMALE&quot;</td><td>8.24246</td><td>-26.11969</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>124</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N43A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>49.9</td><td>16.1</td><td>213</td><td>5400</td><td>&quot;MALE&quot;</td><td>8.3639</td><td>-26.15531</td><td>null</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (344, 17)\n",
       "┌───────────┬────────┬─────────────┬────────┬───┬────────┬─────────────┬─────────────┬─────────────┐\n",
       "│ studyName ┆ Sample ┆ Species     ┆ Region ┆ … ┆ Sex    ┆ Delta 15 N  ┆ Delta 13 C  ┆ Comments    │\n",
       "│ ---       ┆ Number ┆ ---         ┆ ---    ┆   ┆ ---    ┆ (o/oo)      ┆ (o/oo)      ┆ ---         │\n",
       "│ str       ┆ ---    ┆ str         ┆ str    ┆   ┆ str    ┆ ---         ┆ ---         ┆ str         │\n",
       "│           ┆ i64    ┆             ┆        ┆   ┆        ┆ f64         ┆ f64         ┆             │\n",
       "╞═══════════╪════════╪═════════════╪════════╪═══╪════════╪═════════════╪═════════════╪═════════════╡\n",
       "│ PAL0708   ┆ 1      ┆ Adelie      ┆ Anvers ┆ … ┆ MALE   ┆ null        ┆ null        ┆ Not enough  │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆ blood for   │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆ isotopes.   │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0708   ┆ 2      ┆ Adelie      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.94956     ┆ -24.69454   ┆ null        │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0708   ┆ 3      ┆ Adelie      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.36821     ┆ -25.33302   ┆ null        │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0708   ┆ 4      ┆ Adelie      ┆ Anvers ┆ … ┆ null   ┆ null        ┆ null        ┆ Adult not   │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆ sampled.    │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0708   ┆ 5      ┆ Adelie      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.76651     ┆ -25.32426   ┆ null        │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ …         ┆ …      ┆ …           ┆ …      ┆ … ┆ …      ┆ …           ┆ …           ┆ …           │\n",
       "│ PAL0910   ┆ 120    ┆ Gentoo      ┆ Anvers ┆ … ┆ null   ┆ null        ┆ null        ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 121    ┆ Gentoo      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.41151     ┆ -26.13832   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 122    ┆ Gentoo      ┆ Anvers ┆ … ┆ MALE   ┆ 8.30166     ┆ -26.04117   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 123    ┆ Gentoo      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.24246     ┆ -26.11969   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 124    ┆ Gentoo      ┆ Anvers ┆ … ┆ MALE   ┆ 8.3639      ┆ -26.15531   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "└───────────┴────────┴─────────────┴────────┴───┴────────┴─────────────┴─────────────┴─────────────┘"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import polars as pl\n",
    "df = pl.read_csv('penguins_lter.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "be31ce9d-2085-48d3-91e7-267fed1c40d2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (344, 4)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>Sample Number</th><th>Species</th><th>Region</th><th>Island</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>1</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td></tr><tr><td>2</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td></tr><tr><td>3</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td></tr><tr><td>4</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td></tr><tr><td>5</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>120</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td></tr><tr><td>121</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td></tr><tr><td>122</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td></tr><tr><td>123</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td></tr><tr><td>124</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (344, 4)\n",
       "┌───────────────┬─────────────────────────────────┬────────┬───────────┐\n",
       "│ Sample Number ┆ Species                         ┆ Region ┆ Island    │\n",
       "│ ---           ┆ ---                             ┆ ---    ┆ ---       │\n",
       "│ i64           ┆ str                             ┆ str    ┆ str       │\n",
       "╞═══════════════╪═════════════════════════════════╪════════╪═══════════╡\n",
       "│ 1             ┆ Adelie Penguin (Pygoscelis ade… ┆ Anvers ┆ Torgersen │\n",
       "│ 2             ┆ Adelie Penguin (Pygoscelis ade… ┆ Anvers ┆ Torgersen │\n",
       "│ 3             ┆ Adelie Penguin (Pygoscelis ade… ┆ Anvers ┆ Torgersen │\n",
       "│ 4             ┆ Adelie Penguin (Pygoscelis ade… ┆ Anvers ┆ Torgersen │\n",
       "│ 5             ┆ Adelie Penguin (Pygoscelis ade… ┆ Anvers ┆ Torgersen │\n",
       "│ …             ┆ …                               ┆ …      ┆ …         │\n",
       "│ 120           ┆ Gentoo penguin (Pygoscelis pap… ┆ Anvers ┆ Biscoe    │\n",
       "│ 121           ┆ Gentoo penguin (Pygoscelis pap… ┆ Anvers ┆ Biscoe    │\n",
       "│ 122           ┆ Gentoo penguin (Pygoscelis pap… ┆ Anvers ┆ Biscoe    │\n",
       "│ 123           ┆ Gentoo penguin (Pygoscelis pap… ┆ Anvers ┆ Biscoe    │\n",
       "│ 124           ┆ Gentoo penguin (Pygoscelis pap… ┆ Anvers ┆ Biscoe    │\n",
       "└───────────────┴─────────────────────────────────┴────────┴───────────┘"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.select(\n",
    " 'Sample Number',\n",
    " 'Species',\n",
    " 'Region',\n",
    " 'Island')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "471b2827-36cd-4c75-81ae-cc6a803a402c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Gentoo penguin (Pygoscelis papua)'"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Species'][341]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "c7b9f436-c805-4c89-8b30-30922222d01c",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "argument 'columns': 'int' object cannot be converted to 'PyString'",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mTypeError\u001b[39m                                 Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[43]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mdf\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mSpecies\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[32;43m341\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/dataframe/frame.py:1403\u001b[39m, in \u001b[36mDataFrame.__getitem__\u001b[39m\u001b[34m(self, key)\u001b[39m\n\u001b[32m   1266\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__getitem__\u001b[39m(\n\u001b[32m   1267\u001b[39m     \u001b[38;5;28mself\u001b[39m,\n\u001b[32m   1268\u001b[39m     key: (\n\u001b[32m   (...)\u001b[39m\u001b[32m   1277\u001b[39m     ),\n\u001b[32m   1278\u001b[39m ) -> DataFrame | Series | Any:\n\u001b[32m   1279\u001b[39m \u001b[38;5;250m    \u001b[39m\u001b[33;03m\"\"\"\u001b[39;00m\n\u001b[32m   1280\u001b[39m \u001b[33;03m    Get part of the DataFrame as a new DataFrame, Series, or scalar.\u001b[39;00m\n\u001b[32m   1281\u001b[39m \n\u001b[32m   (...)\u001b[39m\u001b[32m   1401\u001b[39m \u001b[33;03m    └─────┴─────┴─────┘\u001b[39;00m\n\u001b[32m   1402\u001b[39m \u001b[33;03m    \"\"\"\u001b[39;00m\n\u001b[32m-> \u001b[39m\u001b[32m1403\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mget_df_item_by_key\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/_utils/getitem.py:148\u001b[39m, in \u001b[36mget_df_item_by_key\u001b[39m\u001b[34m(df, key)\u001b[39m\n\u001b[32m    146\u001b[39m \u001b[38;5;66;03m# Support df[True, False] and df[\"a\", \"b\"] as these are not ambiguous\u001b[39;00m\n\u001b[32m    147\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(row_key, (\u001b[38;5;28mbool\u001b[39m, \u001b[38;5;28mstr\u001b[39m)):\n\u001b[32m--> \u001b[39m\u001b[32m148\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_select_columns\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m  \u001b[38;5;66;03m# type: ignore[arg-type]\u001b[39;00m\n\u001b[32m    150\u001b[39m selection = _select_columns(df, col_key)\n\u001b[32m    152\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m selection.is_empty():\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/_utils/getitem.py:217\u001b[39m, in \u001b[36m_select_columns\u001b[39m\u001b[34m(df, key)\u001b[39m\n\u001b[32m    215\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m _select_columns_by_index(df, key)  \u001b[38;5;66;03m# type: ignore[arg-type]\u001b[39;00m\n\u001b[32m    216\u001b[39m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(first, \u001b[38;5;28mstr\u001b[39m):\n\u001b[32m--> \u001b[39m\u001b[32m217\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_select_columns_by_name\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m  \u001b[38;5;66;03m# type: ignore[arg-type]\u001b[39;00m\n\u001b[32m    218\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m    219\u001b[39m     msg = \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mcannot select columns using Sequence with elements of type \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mqualified_type_name(first)\u001b[38;5;132;01m!r}\u001b[39;00m\u001b[33m\"\u001b[39m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m~/Dropbox/Documents/Teaching/cs503-2026sp/.pixi/envs/default/lib/python3.14/site-packages/polars/_utils/getitem.py:269\u001b[39m, in \u001b[36m_select_columns_by_name\u001b[39m\u001b[34m(df, key)\u001b[39m\n\u001b[32m    268\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m_select_columns_by_name\u001b[39m(df: DataFrame, key: Iterable[\u001b[38;5;28mstr\u001b[39m]) -> DataFrame:\n\u001b[32m--> \u001b[39m\u001b[32m269\u001b[39m     \u001b[38;5;28;01mreturn\u001b[39;00m df._from_pydf(\u001b[43mdf\u001b[49m\u001b[43m.\u001b[49m\u001b[43m_df\u001b[49m\u001b[43m.\u001b[49m\u001b[43mselect\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mlist\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m)\n",
      "\u001b[31mTypeError\u001b[39m: argument 'columns': 'int' object cannot be converted to 'PyString'"
     ]
    }
   ],
   "source": [
    "df['Species',341]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "a07475bc-160b-45f1-91ff-26cef2579c19",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Schema([('studyName', String),\n",
       "        ('Sample Number', Int64),\n",
       "        ('Species', String),\n",
       "        ('Region', String),\n",
       "        ('Island', String),\n",
       "        ('Stage', String),\n",
       "        ('Individual ID', String),\n",
       "        ('Clutch Completion', String),\n",
       "        ('Date Egg', String),\n",
       "        ('Culmen Length (mm)', Float64),\n",
       "        ('Culmen Depth (mm)', Float64),\n",
       "        ('Flipper Length (mm)', Int64),\n",
       "        ('Body Mass (g)', Int64),\n",
       "        ('Sex', String),\n",
       "        ('Delta 15 N (o/oo)', Float64),\n",
       "        ('Delta 13 C (o/oo)', Float64),\n",
       "        ('Comments', String)])"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.schema"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "fff447bb-8541-440c-8d6f-cf20b88d445e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (168, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>studyName</th><th>Sample Number</th><th>Species</th><th>Region</th><th>Island</th><th>Stage</th><th>Individual ID</th><th>Clutch Completion</th><th>Date Egg</th><th>Culmen Length (mm)</th><th>Culmen Depth (mm)</th><th>Flipper Length (mm)</th><th>Body Mass (g)</th><th>Sex</th><th>Delta 15 N (o/oo)</th><th>Delta 13 C (o/oo)</th><th>Comments</th></tr><tr><td>str</td><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>i64</td><td>i64</td><td>str</td><td>f64</td><td>f64</td><td>str</td></tr></thead><tbody><tr><td>&quot;PAL0708&quot;</td><td>21</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N11A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/12/07&quot;</td><td>37.8</td><td>18.3</td><td>174</td><td>3400</td><td>&quot;FEMALE&quot;</td><td>8.73762</td><td>-25.09383</td><td>null</td></tr><tr><td>&quot;PAL0708&quot;</td><td>22</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N11A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/12/07&quot;</td><td>37.7</td><td>18.7</td><td>180</td><td>3600</td><td>&quot;MALE&quot;</td><td>8.66271</td><td>-25.0639</td><td>null</td></tr><tr><td>&quot;PAL0708&quot;</td><td>23</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N12A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/12/07&quot;</td><td>35.9</td><td>19.2</td><td>189</td><td>3800</td><td>&quot;FEMALE&quot;</td><td>9.22286</td><td>-25.03474</td><td>null</td></tr><tr><td>&quot;PAL0708&quot;</td><td>24</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N12A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/12/07&quot;</td><td>38.2</td><td>18.1</td><td>185</td><td>3950</td><td>&quot;MALE&quot;</td><td>8.43423</td><td>-25.22664</td><td>null</td></tr><tr><td>&quot;PAL0708&quot;</td><td>25</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N13A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/10/07&quot;</td><td>38.8</td><td>17.2</td><td>180</td><td>3800</td><td>&quot;MALE&quot;</td><td>9.63954</td><td>-25.29856</td><td>null</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;PAL0910&quot;</td><td>120</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N38A2&quot;</td><td>&quot;No&quot;</td><td>&quot;12/1/09&quot;</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>121</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N39A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>46.8</td><td>14.3</td><td>215</td><td>4850</td><td>&quot;FEMALE&quot;</td><td>8.41151</td><td>-26.13832</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>122</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N39A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>50.4</td><td>15.7</td><td>222</td><td>5750</td><td>&quot;MALE&quot;</td><td>8.30166</td><td>-26.04117</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>123</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N43A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>45.2</td><td>14.8</td><td>212</td><td>5200</td><td>&quot;FEMALE&quot;</td><td>8.24246</td><td>-26.11969</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>124</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N43A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>49.9</td><td>16.1</td><td>213</td><td>5400</td><td>&quot;MALE&quot;</td><td>8.3639</td><td>-26.15531</td><td>null</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (168, 17)\n",
       "┌───────────┬────────┬──────────────┬────────┬───┬────────┬──────────────┬──────────────┬──────────┐\n",
       "│ studyName ┆ Sample ┆ Species      ┆ Region ┆ … ┆ Sex    ┆ Delta 15 N   ┆ Delta 13 C   ┆ Comments │\n",
       "│ ---       ┆ Number ┆ ---          ┆ ---    ┆   ┆ ---    ┆ (o/oo)       ┆ (o/oo)       ┆ ---      │\n",
       "│ str       ┆ ---    ┆ str          ┆ str    ┆   ┆ str    ┆ ---          ┆ ---          ┆ str      │\n",
       "│           ┆ i64    ┆              ┆        ┆   ┆        ┆ f64          ┆ f64          ┆          │\n",
       "╞═══════════╪════════╪══════════════╪════════╪═══╪════════╪══════════════╪══════════════╪══════════╡\n",
       "│ PAL0708   ┆ 21     ┆ Adelie       ┆ Anvers ┆ … ┆ FEMALE ┆ 8.73762      ┆ -25.09383    ┆ null     │\n",
       "│           ┆        ┆ Penguin      ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ (Pygoscelis  ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ ade…         ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│ PAL0708   ┆ 22     ┆ Adelie       ┆ Anvers ┆ … ┆ MALE   ┆ 8.66271      ┆ -25.0639     ┆ null     │\n",
       "│           ┆        ┆ Penguin      ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ (Pygoscelis  ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ ade…         ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│ PAL0708   ┆ 23     ┆ Adelie       ┆ Anvers ┆ … ┆ FEMALE ┆ 9.22286      ┆ -25.03474    ┆ null     │\n",
       "│           ┆        ┆ Penguin      ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ (Pygoscelis  ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ ade…         ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│ PAL0708   ┆ 24     ┆ Adelie       ┆ Anvers ┆ … ┆ MALE   ┆ 8.43423      ┆ -25.22664    ┆ null     │\n",
       "│           ┆        ┆ Penguin      ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ (Pygoscelis  ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ ade…         ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│ PAL0708   ┆ 25     ┆ Adelie       ┆ Anvers ┆ … ┆ MALE   ┆ 9.63954      ┆ -25.29856    ┆ null     │\n",
       "│           ┆        ┆ Penguin      ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ (Pygoscelis  ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ ade…         ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│ …         ┆ …      ┆ …            ┆ …      ┆ … ┆ …      ┆ …            ┆ …            ┆ …        │\n",
       "│ PAL0910   ┆ 120    ┆ Gentoo       ┆ Anvers ┆ … ┆ null   ┆ null         ┆ null         ┆ null     │\n",
       "│           ┆        ┆ penguin      ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ (Pygoscelis  ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ pap…         ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│ PAL0910   ┆ 121    ┆ Gentoo       ┆ Anvers ┆ … ┆ FEMALE ┆ 8.41151      ┆ -26.13832    ┆ null     │\n",
       "│           ┆        ┆ penguin      ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ (Pygoscelis  ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ pap…         ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│ PAL0910   ┆ 122    ┆ Gentoo       ┆ Anvers ┆ … ┆ MALE   ┆ 8.30166      ┆ -26.04117    ┆ null     │\n",
       "│           ┆        ┆ penguin      ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ (Pygoscelis  ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ pap…         ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│ PAL0910   ┆ 123    ┆ Gentoo       ┆ Anvers ┆ … ┆ FEMALE ┆ 8.24246      ┆ -26.11969    ┆ null     │\n",
       "│           ┆        ┆ penguin      ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ (Pygoscelis  ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ pap…         ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│ PAL0910   ┆ 124    ┆ Gentoo       ┆ Anvers ┆ … ┆ MALE   ┆ 8.3639       ┆ -26.15531    ┆ null     │\n",
       "│           ┆        ┆ penguin      ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ (Pygoscelis  ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "│           ┆        ┆ pap…         ┆        ┆   ┆        ┆              ┆              ┆          │\n",
       "└───────────┴────────┴──────────────┴────────┴───┴────────┴──────────────┴──────────────┴──────────┘"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.filter(pl.col('Island') == \"Biscoe\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "4ec0729b-6500-4681-9776-dd42d577995d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (242, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>studyName</th><th>Sample Number</th><th>Species</th><th>Region</th><th>Island</th><th>Stage</th><th>Individual ID</th><th>Clutch Completion</th><th>Date Egg</th><th>Culmen Length (mm)</th><th>Culmen Depth (mm)</th><th>Flipper Length (mm)</th><th>Body Mass (g)</th><th>Sex</th><th>Delta 15 N (o/oo)</th><th>Delta 13 C (o/oo)</th><th>Comments</th></tr><tr><td>str</td><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>i64</td><td>i64</td><td>str</td><td>f64</td><td>f64</td><td>str</td></tr></thead><tbody><tr><td>&quot;PAL0708&quot;</td><td>3</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N2A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/16/07&quot;</td><td>40.3</td><td>18.0</td><td>195</td><td>3250</td><td>&quot;FEMALE&quot;</td><td>8.36821</td><td>-25.33302</td><td>null</td></tr><tr><td>&quot;PAL0708&quot;</td><td>10</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N5A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/9/07&quot;</td><td>42.0</td><td>20.2</td><td>190</td><td>4250</td><td>null</td><td>9.13362</td><td>-25.09368</td><td>&quot;No blood sample obtained for s…</td></tr><tr><td>&quot;PAL0708&quot;</td><td>13</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N7A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/15/07&quot;</td><td>41.1</td><td>17.6</td><td>182</td><td>3200</td><td>&quot;FEMALE&quot;</td><td>null</td><td>null</td><td>&quot;Not enough blood for isotopes.&quot;</td></tr><tr><td>&quot;PAL0708&quot;</td><td>18</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N9A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/12/07&quot;</td><td>42.5</td><td>20.7</td><td>197</td><td>4500</td><td>&quot;MALE&quot;</td><td>8.67538</td><td>-25.13993</td><td>null</td></tr><tr><td>&quot;PAL0708&quot;</td><td>20</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Torgersen&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N10A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/16/07&quot;</td><td>46.0</td><td>21.5</td><td>194</td><td>4200</td><td>&quot;MALE&quot;</td><td>9.11616</td><td>-24.77227</td><td>null</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;PAL0910&quot;</td><td>119</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N38A1&quot;</td><td>&quot;No&quot;</td><td>&quot;12/1/09&quot;</td><td>47.2</td><td>13.7</td><td>214</td><td>4925</td><td>&quot;FEMALE&quot;</td><td>7.99184</td><td>-26.20538</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>121</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N39A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>46.8</td><td>14.3</td><td>215</td><td>4850</td><td>&quot;FEMALE&quot;</td><td>8.41151</td><td>-26.13832</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>122</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N39A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>50.4</td><td>15.7</td><td>222</td><td>5750</td><td>&quot;MALE&quot;</td><td>8.30166</td><td>-26.04117</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>123</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N43A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>45.2</td><td>14.8</td><td>212</td><td>5200</td><td>&quot;FEMALE&quot;</td><td>8.24246</td><td>-26.11969</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>124</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N43A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>49.9</td><td>16.1</td><td>213</td><td>5400</td><td>&quot;MALE&quot;</td><td>8.3639</td><td>-26.15531</td><td>null</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (242, 17)\n",
       "┌───────────┬────────┬─────────────┬────────┬───┬────────┬─────────────┬─────────────┬─────────────┐\n",
       "│ studyName ┆ Sample ┆ Species     ┆ Region ┆ … ┆ Sex    ┆ Delta 15 N  ┆ Delta 13 C  ┆ Comments    │\n",
       "│ ---       ┆ Number ┆ ---         ┆ ---    ┆   ┆ ---    ┆ (o/oo)      ┆ (o/oo)      ┆ ---         │\n",
       "│ str       ┆ ---    ┆ str         ┆ str    ┆   ┆ str    ┆ ---         ┆ ---         ┆ str         │\n",
       "│           ┆ i64    ┆             ┆        ┆   ┆        ┆ f64         ┆ f64         ┆             │\n",
       "╞═══════════╪════════╪═════════════╪════════╪═══╪════════╪═════════════╪═════════════╪═════════════╡\n",
       "│ PAL0708   ┆ 3      ┆ Adelie      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.36821     ┆ -25.33302   ┆ null        │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0708   ┆ 10     ┆ Adelie      ┆ Anvers ┆ … ┆ null   ┆ 9.13362     ┆ -25.09368   ┆ No blood    │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆ sample      │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆ obtained    │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆ for s…      │\n",
       "│ PAL0708   ┆ 13     ┆ Adelie      ┆ Anvers ┆ … ┆ FEMALE ┆ null        ┆ null        ┆ Not enough  │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆ blood for   │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆ isotopes.   │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0708   ┆ 18     ┆ Adelie      ┆ Anvers ┆ … ┆ MALE   ┆ 8.67538     ┆ -25.13993   ┆ null        │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0708   ┆ 20     ┆ Adelie      ┆ Anvers ┆ … ┆ MALE   ┆ 9.11616     ┆ -24.77227   ┆ null        │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ …         ┆ …      ┆ …           ┆ …      ┆ … ┆ …      ┆ …           ┆ …           ┆ …           │\n",
       "│ PAL0910   ┆ 119    ┆ Gentoo      ┆ Anvers ┆ … ┆ FEMALE ┆ 7.99184     ┆ -26.20538   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 121    ┆ Gentoo      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.41151     ┆ -26.13832   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 122    ┆ Gentoo      ┆ Anvers ┆ … ┆ MALE   ┆ 8.30166     ┆ -26.04117   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 123    ┆ Gentoo      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.24246     ┆ -26.11969   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 124    ┆ Gentoo      ┆ Anvers ┆ … ┆ MALE   ┆ 8.3639      ┆ -26.15531   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "└───────────┴────────┴─────────────┴────────┴───┴────────┴─────────────┴─────────────┴─────────────┘"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.filter(pl.col(\"Culmen Length (mm)\") > 40)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "967ef673-7bfc-4fb2-b376-67fe2fbef3da",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (139, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>studyName</th><th>Sample Number</th><th>Species</th><th>Region</th><th>Island</th><th>Stage</th><th>Individual ID</th><th>Clutch Completion</th><th>Date Egg</th><th>Culmen Length (mm)</th><th>Culmen Depth (mm)</th><th>Flipper Length (mm)</th><th>Body Mass (g)</th><th>Sex</th><th>Delta 15 N (o/oo)</th><th>Delta 13 C (o/oo)</th><th>Comments</th></tr><tr><td>str</td><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>i64</td><td>i64</td><td>str</td><td>f64</td><td>f64</td><td>str</td></tr></thead><tbody><tr><td>&quot;PAL0708&quot;</td><td>27</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N17A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/12/07&quot;</td><td>40.6</td><td>18.6</td><td>183</td><td>3550</td><td>&quot;MALE&quot;</td><td>8.93997</td><td>-25.36288</td><td>null</td></tr><tr><td>&quot;PAL0708&quot;</td><td>28</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N17A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/12/07&quot;</td><td>40.5</td><td>17.9</td><td>187</td><td>3200</td><td>&quot;FEMALE&quot;</td><td>8.08138</td><td>-25.49448</td><td>null</td></tr><tr><td>&quot;PAL0708&quot;</td><td>30</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N18A2&quot;</td><td>&quot;No&quot;</td><td>&quot;11/10/07&quot;</td><td>40.5</td><td>18.9</td><td>180</td><td>3950</td><td>&quot;MALE&quot;</td><td>8.90027</td><td>-25.11609</td><td>&quot;Nest never observed with full …</td></tr><tr><td>&quot;PAL0809&quot;</td><td>52</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N21A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/6/08&quot;</td><td>40.1</td><td>18.9</td><td>188</td><td>4300</td><td>&quot;MALE&quot;</td><td>8.51362</td><td>-26.55602</td><td>null</td></tr><tr><td>&quot;PAL0809&quot;</td><td>54</td><td>&quot;Adelie Penguin (Pygoscelis ade…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N22A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/9/08&quot;</td><td>42.0</td><td>19.5</td><td>200</td><td>4050</td><td>&quot;MALE&quot;</td><td>8.48095</td><td>-26.3146</td><td>null</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;PAL0910&quot;</td><td>119</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N38A1&quot;</td><td>&quot;No&quot;</td><td>&quot;12/1/09&quot;</td><td>47.2</td><td>13.7</td><td>214</td><td>4925</td><td>&quot;FEMALE&quot;</td><td>7.99184</td><td>-26.20538</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>121</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N39A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>46.8</td><td>14.3</td><td>215</td><td>4850</td><td>&quot;FEMALE&quot;</td><td>8.41151</td><td>-26.13832</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>122</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N39A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>50.4</td><td>15.7</td><td>222</td><td>5750</td><td>&quot;MALE&quot;</td><td>8.30166</td><td>-26.04117</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>123</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N43A1&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>45.2</td><td>14.8</td><td>212</td><td>5200</td><td>&quot;FEMALE&quot;</td><td>8.24246</td><td>-26.11969</td><td>null</td></tr><tr><td>&quot;PAL0910&quot;</td><td>124</td><td>&quot;Gentoo penguin (Pygoscelis pap…</td><td>&quot;Anvers&quot;</td><td>&quot;Biscoe&quot;</td><td>&quot;Adult, 1 Egg Stage&quot;</td><td>&quot;N43A2&quot;</td><td>&quot;Yes&quot;</td><td>&quot;11/22/09&quot;</td><td>49.9</td><td>16.1</td><td>213</td><td>5400</td><td>&quot;MALE&quot;</td><td>8.3639</td><td>-26.15531</td><td>null</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (139, 17)\n",
       "┌───────────┬────────┬─────────────┬────────┬───┬────────┬─────────────┬─────────────┬─────────────┐\n",
       "│ studyName ┆ Sample ┆ Species     ┆ Region ┆ … ┆ Sex    ┆ Delta 15 N  ┆ Delta 13 C  ┆ Comments    │\n",
       "│ ---       ┆ Number ┆ ---         ┆ ---    ┆   ┆ ---    ┆ (o/oo)      ┆ (o/oo)      ┆ ---         │\n",
       "│ str       ┆ ---    ┆ str         ┆ str    ┆   ┆ str    ┆ ---         ┆ ---         ┆ str         │\n",
       "│           ┆ i64    ┆             ┆        ┆   ┆        ┆ f64         ┆ f64         ┆             │\n",
       "╞═══════════╪════════╪═════════════╪════════╪═══╪════════╪═════════════╪═════════════╪═════════════╡\n",
       "│ PAL0708   ┆ 27     ┆ Adelie      ┆ Anvers ┆ … ┆ MALE   ┆ 8.93997     ┆ -25.36288   ┆ null        │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0708   ┆ 28     ┆ Adelie      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.08138     ┆ -25.49448   ┆ null        │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0708   ┆ 30     ┆ Adelie      ┆ Anvers ┆ … ┆ MALE   ┆ 8.90027     ┆ -25.11609   ┆ Nest never  │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆ observed    │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆ with full … │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0809   ┆ 52     ┆ Adelie      ┆ Anvers ┆ … ┆ MALE   ┆ 8.51362     ┆ -26.55602   ┆ null        │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0809   ┆ 54     ┆ Adelie      ┆ Anvers ┆ … ┆ MALE   ┆ 8.48095     ┆ -26.3146    ┆ null        │\n",
       "│           ┆        ┆ Penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ ade…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ …         ┆ …      ┆ …           ┆ …      ┆ … ┆ …      ┆ …           ┆ …           ┆ …           │\n",
       "│ PAL0910   ┆ 119    ┆ Gentoo      ┆ Anvers ┆ … ┆ FEMALE ┆ 7.99184     ┆ -26.20538   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 121    ┆ Gentoo      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.41151     ┆ -26.13832   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 122    ┆ Gentoo      ┆ Anvers ┆ … ┆ MALE   ┆ 8.30166     ┆ -26.04117   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 123    ┆ Gentoo      ┆ Anvers ┆ … ┆ FEMALE ┆ 8.24246     ┆ -26.11969   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│ PAL0910   ┆ 124    ┆ Gentoo      ┆ Anvers ┆ … ┆ MALE   ┆ 8.3639      ┆ -26.15531   ┆ null        │\n",
       "│           ┆        ┆ penguin     ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ (Pygoscelis ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "│           ┆        ┆ pap…        ┆        ┆   ┆        ┆             ┆             ┆             │\n",
       "└───────────┴────────┴─────────────┴────────┴───┴────────┴─────────────┴─────────────┴─────────────┘"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.filter((pl.col(\"Culmen Length (mm)\") > 40) & (pl.col(\"Island\") == \"Biscoe\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "3811ae71-fa9c-43cf-a801-e1fb92af24c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (3,)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>Island</th></tr><tr><td>str</td></tr></thead><tbody><tr><td>&quot;Torgersen&quot;</td></tr><tr><td>&quot;Dream&quot;</td></tr><tr><td>&quot;Biscoe&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (3,)\n",
       "Series: 'Island' [str]\n",
       "[\n",
       "\t\"Torgersen\"\n",
       "\t\"Dream\"\n",
       "\t\"Biscoe\"\n",
       "]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Island'].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "2cf86b0d-c256-4436-b990-27e7db80ed73",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (3, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>Island</th><th>count</th></tr><tr><td>str</td><td>u32</td></tr></thead><tbody><tr><td>&quot;Dream&quot;</td><td>124</td></tr><tr><td>&quot;Biscoe&quot;</td><td>168</td></tr><tr><td>&quot;Torgersen&quot;</td><td>52</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (3, 2)\n",
       "┌───────────┬───────┐\n",
       "│ Island    ┆ count │\n",
       "│ ---       ┆ ---   │\n",
       "│ str       ┆ u32   │\n",
       "╞═══════════╪═══════╡\n",
       "│ Dream     ┆ 124   │\n",
       "│ Biscoe    ┆ 168   │\n",
       "│ Torgersen ┆ 52    │\n",
       "└───────────┴───────┘"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Island'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "6cda93e4-aab8-4677-a097-8b7e199f00af",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (3, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>Island</th><th>Culmen Length (mm)</th></tr><tr><td>str</td><td>f64</td></tr></thead><tbody><tr><td>&quot;Torgersen&quot;</td><td>38.95098</td></tr><tr><td>&quot;Biscoe&quot;</td><td>45.257485</td></tr><tr><td>&quot;Dream&quot;</td><td>44.167742</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (3, 2)\n",
       "┌───────────┬────────────────────┐\n",
       "│ Island    ┆ Culmen Length (mm) │\n",
       "│ ---       ┆ ---                │\n",
       "│ str       ┆ f64                │\n",
       "╞═══════════╪════════════════════╡\n",
       "│ Torgersen ┆ 38.95098           │\n",
       "│ Biscoe    ┆ 45.257485          │\n",
       "│ Dream     ┆ 44.167742          │\n",
       "└───────────┴────────────────────┘"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.group_by('Island').agg(pl.col('Culmen Length (mm)').mean())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9b1ce18d-3611-4408-a486-b59ab23d2694",
   "metadata": {},
   "source": [
    "##### pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "66506c78-eb24-4938-95e9-5a0c71a96944",
   "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>studyName</th>\n",
       "      <th>Sample Number</th>\n",
       "      <th>Species</th>\n",
       "      <th>Region</th>\n",
       "      <th>Island</th>\n",
       "      <th>Stage</th>\n",
       "      <th>Individual ID</th>\n",
       "      <th>Clutch Completion</th>\n",
       "      <th>Date Egg</th>\n",
       "      <th>Culmen Length (mm)</th>\n",
       "      <th>Culmen Depth (mm)</th>\n",
       "      <th>Flipper Length (mm)</th>\n",
       "      <th>Body Mass (g)</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Delta 15 N (o/oo)</th>\n",
       "      <th>Delta 13 C (o/oo)</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>1</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Torgersen</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N1A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/11/07</td>\n",
       "      <td>39.1</td>\n",
       "      <td>18.7</td>\n",
       "      <td>181.0</td>\n",
       "      <td>3750.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Not enough blood for isotopes.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>2</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Torgersen</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N1A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/11/07</td>\n",
       "      <td>39.5</td>\n",
       "      <td>17.4</td>\n",
       "      <td>186.0</td>\n",
       "      <td>3800.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.94956</td>\n",
       "      <td>-24.69454</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>3</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Torgersen</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N2A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/16/07</td>\n",
       "      <td>40.3</td>\n",
       "      <td>18.0</td>\n",
       "      <td>195.0</td>\n",
       "      <td>3250.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.36821</td>\n",
       "      <td>-25.33302</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>4</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Torgersen</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N2A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/16/07</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Adult not sampled.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>5</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Torgersen</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N3A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/16/07</td>\n",
       "      <td>36.7</td>\n",
       "      <td>19.3</td>\n",
       "      <td>193.0</td>\n",
       "      <td>3450.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.76651</td>\n",
       "      <td>-25.32426</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>339</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>120</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N38A2</td>\n",
       "      <td>No</td>\n",
       "      <td>12/1/09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>340</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>121</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N39A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>46.8</td>\n",
       "      <td>14.3</td>\n",
       "      <td>215.0</td>\n",
       "      <td>4850.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.41151</td>\n",
       "      <td>-26.13832</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>341</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>122</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N39A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>50.4</td>\n",
       "      <td>15.7</td>\n",
       "      <td>222.0</td>\n",
       "      <td>5750.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.30166</td>\n",
       "      <td>-26.04117</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>342</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>123</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N43A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>45.2</td>\n",
       "      <td>14.8</td>\n",
       "      <td>212.0</td>\n",
       "      <td>5200.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.24246</td>\n",
       "      <td>-26.11969</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>343</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>124</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N43A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>49.9</td>\n",
       "      <td>16.1</td>\n",
       "      <td>213.0</td>\n",
       "      <td>5400.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.36390</td>\n",
       "      <td>-26.15531</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>344 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    studyName  Sample Number                              Species  Region  \\\n",
       "0     PAL0708              1  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "1     PAL0708              2  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "2     PAL0708              3  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "3     PAL0708              4  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "4     PAL0708              5  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "..        ...            ...                                  ...     ...   \n",
       "339   PAL0910            120    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "340   PAL0910            121    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "341   PAL0910            122    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "342   PAL0910            123    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "343   PAL0910            124    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "\n",
       "        Island               Stage Individual ID Clutch Completion  Date Egg  \\\n",
       "0    Torgersen  Adult, 1 Egg Stage          N1A1               Yes  11/11/07   \n",
       "1    Torgersen  Adult, 1 Egg Stage          N1A2               Yes  11/11/07   \n",
       "2    Torgersen  Adult, 1 Egg Stage          N2A1               Yes  11/16/07   \n",
       "3    Torgersen  Adult, 1 Egg Stage          N2A2               Yes  11/16/07   \n",
       "4    Torgersen  Adult, 1 Egg Stage          N3A1               Yes  11/16/07   \n",
       "..         ...                 ...           ...               ...       ...   \n",
       "339     Biscoe  Adult, 1 Egg Stage         N38A2                No   12/1/09   \n",
       "340     Biscoe  Adult, 1 Egg Stage         N39A1               Yes  11/22/09   \n",
       "341     Biscoe  Adult, 1 Egg Stage         N39A2               Yes  11/22/09   \n",
       "342     Biscoe  Adult, 1 Egg Stage         N43A1               Yes  11/22/09   \n",
       "343     Biscoe  Adult, 1 Egg Stage         N43A2               Yes  11/22/09   \n",
       "\n",
       "     Culmen Length (mm)  Culmen Depth (mm)  Flipper Length (mm)  \\\n",
       "0                  39.1               18.7                181.0   \n",
       "1                  39.5               17.4                186.0   \n",
       "2                  40.3               18.0                195.0   \n",
       "3                   NaN                NaN                  NaN   \n",
       "4                  36.7               19.3                193.0   \n",
       "..                  ...                ...                  ...   \n",
       "339                 NaN                NaN                  NaN   \n",
       "340                46.8               14.3                215.0   \n",
       "341                50.4               15.7                222.0   \n",
       "342                45.2               14.8                212.0   \n",
       "343                49.9               16.1                213.0   \n",
       "\n",
       "     Body Mass (g)     Sex  Delta 15 N (o/oo)  Delta 13 C (o/oo)  \\\n",
       "0           3750.0    MALE                NaN                NaN   \n",
       "1           3800.0  FEMALE            8.94956          -24.69454   \n",
       "2           3250.0  FEMALE            8.36821          -25.33302   \n",
       "3              NaN     NaN                NaN                NaN   \n",
       "4           3450.0  FEMALE            8.76651          -25.32426   \n",
       "..             ...     ...                ...                ...   \n",
       "339            NaN     NaN                NaN                NaN   \n",
       "340         4850.0  FEMALE            8.41151          -26.13832   \n",
       "341         5750.0    MALE            8.30166          -26.04117   \n",
       "342         5200.0  FEMALE            8.24246          -26.11969   \n",
       "343         5400.0    MALE            8.36390          -26.15531   \n",
       "\n",
       "                           Comments  \n",
       "0    Not enough blood for isotopes.  \n",
       "1                               NaN  \n",
       "2                               NaN  \n",
       "3                Adult not sampled.  \n",
       "4                               NaN  \n",
       "..                              ...  \n",
       "339                             NaN  \n",
       "340                             NaN  \n",
       "341                             NaN  \n",
       "342                             NaN  \n",
       "343                             NaN  \n",
       "\n",
       "[344 rows x 17 columns]"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "dfa = pd.read_csv('penguins_lter.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "bab9e298-c59b-4533-b429-b826e49bc4a5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 344 entries, 0 to 343\n",
      "Data columns (total 17 columns):\n",
      " #   Column               Non-Null Count  Dtype  \n",
      "---  ------               --------------  -----  \n",
      " 0   studyName            344 non-null    object \n",
      " 1   Sample Number        344 non-null    int64  \n",
      " 2   Species              344 non-null    object \n",
      " 3   Region               344 non-null    object \n",
      " 4   Island               344 non-null    object \n",
      " 5   Stage                344 non-null    object \n",
      " 6   Individual ID        344 non-null    object \n",
      " 7   Clutch Completion    344 non-null    object \n",
      " 8   Date Egg             344 non-null    object \n",
      " 9   Culmen Length (mm)   342 non-null    float64\n",
      " 10  Culmen Depth (mm)    342 non-null    float64\n",
      " 11  Flipper Length (mm)  342 non-null    float64\n",
      " 12  Body Mass (g)        342 non-null    float64\n",
      " 13  Sex                  334 non-null    object \n",
      " 14  Delta 15 N (o/oo)    330 non-null    float64\n",
      " 15  Delta 13 C (o/oo)    331 non-null    float64\n",
      " 16  Comments             26 non-null     object \n",
      "dtypes: float64(6), int64(1), object(10)\n",
      "memory usage: 45.8+ KB\n"
     ]
    }
   ],
   "source": [
    "dfa.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "d4477d3a-321e-4f71-a236-cbdc6283b129",
   "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>studyName</th>\n",
       "      <th>Sample Number</th>\n",
       "      <th>Species</th>\n",
       "      <th>Region</th>\n",
       "      <th>Island</th>\n",
       "      <th>Stage</th>\n",
       "      <th>Individual ID</th>\n",
       "      <th>Clutch Completion</th>\n",
       "      <th>Date Egg</th>\n",
       "      <th>Culmen Length (mm)</th>\n",
       "      <th>Culmen Depth (mm)</th>\n",
       "      <th>Flipper Length (mm)</th>\n",
       "      <th>Body Mass (g)</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Delta 15 N (o/oo)</th>\n",
       "      <th>Delta 13 C (o/oo)</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>21</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N11A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/12/07</td>\n",
       "      <td>37.8</td>\n",
       "      <td>18.3</td>\n",
       "      <td>174.0</td>\n",
       "      <td>3400.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.73762</td>\n",
       "      <td>-25.09383</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>22</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N11A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/12/07</td>\n",
       "      <td>37.7</td>\n",
       "      <td>18.7</td>\n",
       "      <td>180.0</td>\n",
       "      <td>3600.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.66271</td>\n",
       "      <td>-25.06390</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>23</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N12A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/12/07</td>\n",
       "      <td>35.9</td>\n",
       "      <td>19.2</td>\n",
       "      <td>189.0</td>\n",
       "      <td>3800.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>9.22286</td>\n",
       "      <td>-25.03474</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>24</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N12A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/12/07</td>\n",
       "      <td>38.2</td>\n",
       "      <td>18.1</td>\n",
       "      <td>185.0</td>\n",
       "      <td>3950.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.43423</td>\n",
       "      <td>-25.22664</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>25</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N13A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/10/07</td>\n",
       "      <td>38.8</td>\n",
       "      <td>17.2</td>\n",
       "      <td>180.0</td>\n",
       "      <td>3800.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>9.63954</td>\n",
       "      <td>-25.29856</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>339</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>120</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N38A2</td>\n",
       "      <td>No</td>\n",
       "      <td>12/1/09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>340</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>121</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N39A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>46.8</td>\n",
       "      <td>14.3</td>\n",
       "      <td>215.0</td>\n",
       "      <td>4850.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.41151</td>\n",
       "      <td>-26.13832</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>341</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>122</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N39A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>50.4</td>\n",
       "      <td>15.7</td>\n",
       "      <td>222.0</td>\n",
       "      <td>5750.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.30166</td>\n",
       "      <td>-26.04117</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>342</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>123</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N43A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>45.2</td>\n",
       "      <td>14.8</td>\n",
       "      <td>212.0</td>\n",
       "      <td>5200.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.24246</td>\n",
       "      <td>-26.11969</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>343</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>124</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N43A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>49.9</td>\n",
       "      <td>16.1</td>\n",
       "      <td>213.0</td>\n",
       "      <td>5400.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.36390</td>\n",
       "      <td>-26.15531</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>168 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    studyName  Sample Number                              Species  Region  \\\n",
       "20    PAL0708             21  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "21    PAL0708             22  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "22    PAL0708             23  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "23    PAL0708             24  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "24    PAL0708             25  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "..        ...            ...                                  ...     ...   \n",
       "339   PAL0910            120    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "340   PAL0910            121    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "341   PAL0910            122    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "342   PAL0910            123    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "343   PAL0910            124    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "\n",
       "     Island               Stage Individual ID Clutch Completion  Date Egg  \\\n",
       "20   Biscoe  Adult, 1 Egg Stage         N11A1               Yes  11/12/07   \n",
       "21   Biscoe  Adult, 1 Egg Stage         N11A2               Yes  11/12/07   \n",
       "22   Biscoe  Adult, 1 Egg Stage         N12A1               Yes  11/12/07   \n",
       "23   Biscoe  Adult, 1 Egg Stage         N12A2               Yes  11/12/07   \n",
       "24   Biscoe  Adult, 1 Egg Stage         N13A1               Yes  11/10/07   \n",
       "..      ...                 ...           ...               ...       ...   \n",
       "339  Biscoe  Adult, 1 Egg Stage         N38A2                No   12/1/09   \n",
       "340  Biscoe  Adult, 1 Egg Stage         N39A1               Yes  11/22/09   \n",
       "341  Biscoe  Adult, 1 Egg Stage         N39A2               Yes  11/22/09   \n",
       "342  Biscoe  Adult, 1 Egg Stage         N43A1               Yes  11/22/09   \n",
       "343  Biscoe  Adult, 1 Egg Stage         N43A2               Yes  11/22/09   \n",
       "\n",
       "     Culmen Length (mm)  Culmen Depth (mm)  Flipper Length (mm)  \\\n",
       "20                 37.8               18.3                174.0   \n",
       "21                 37.7               18.7                180.0   \n",
       "22                 35.9               19.2                189.0   \n",
       "23                 38.2               18.1                185.0   \n",
       "24                 38.8               17.2                180.0   \n",
       "..                  ...                ...                  ...   \n",
       "339                 NaN                NaN                  NaN   \n",
       "340                46.8               14.3                215.0   \n",
       "341                50.4               15.7                222.0   \n",
       "342                45.2               14.8                212.0   \n",
       "343                49.9               16.1                213.0   \n",
       "\n",
       "     Body Mass (g)     Sex  Delta 15 N (o/oo)  Delta 13 C (o/oo) Comments  \n",
       "20          3400.0  FEMALE            8.73762          -25.09383      NaN  \n",
       "21          3600.0    MALE            8.66271          -25.06390      NaN  \n",
       "22          3800.0  FEMALE            9.22286          -25.03474      NaN  \n",
       "23          3950.0    MALE            8.43423          -25.22664      NaN  \n",
       "24          3800.0    MALE            9.63954          -25.29856      NaN  \n",
       "..             ...     ...                ...                ...      ...  \n",
       "339            NaN     NaN                NaN                NaN      NaN  \n",
       "340         4850.0  FEMALE            8.41151          -26.13832      NaN  \n",
       "341         5750.0    MALE            8.30166          -26.04117      NaN  \n",
       "342         5200.0  FEMALE            8.24246          -26.11969      NaN  \n",
       "343         5400.0    MALE            8.36390          -26.15531      NaN  \n",
       "\n",
       "[168 rows x 17 columns]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa[dfa.Island == 'Biscoe']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "f75838ec-e7ae-4dcb-aab9-2427f1cdde40",
   "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>studyName</th>\n",
       "      <th>Sample Number</th>\n",
       "      <th>Species</th>\n",
       "      <th>Region</th>\n",
       "      <th>Island</th>\n",
       "      <th>Stage</th>\n",
       "      <th>Individual ID</th>\n",
       "      <th>Clutch Completion</th>\n",
       "      <th>Date Egg</th>\n",
       "      <th>Culmen Length (mm)</th>\n",
       "      <th>Culmen Depth (mm)</th>\n",
       "      <th>Flipper Length (mm)</th>\n",
       "      <th>Body Mass (g)</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Delta 15 N (o/oo)</th>\n",
       "      <th>Delta 13 C (o/oo)</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>3</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Torgersen</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N2A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/16/07</td>\n",
       "      <td>40.3</td>\n",
       "      <td>18.0</td>\n",
       "      <td>195.0</td>\n",
       "      <td>3250.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.36821</td>\n",
       "      <td>-25.33302</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>10</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Torgersen</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N5A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/9/07</td>\n",
       "      <td>42.0</td>\n",
       "      <td>20.2</td>\n",
       "      <td>190.0</td>\n",
       "      <td>4250.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.13362</td>\n",
       "      <td>-25.09368</td>\n",
       "      <td>No blood sample obtained for sexing.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>13</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Torgersen</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N7A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/15/07</td>\n",
       "      <td>41.1</td>\n",
       "      <td>17.6</td>\n",
       "      <td>182.0</td>\n",
       "      <td>3200.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Not enough blood for isotopes.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>18</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Torgersen</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N9A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/12/07</td>\n",
       "      <td>42.5</td>\n",
       "      <td>20.7</td>\n",
       "      <td>197.0</td>\n",
       "      <td>4500.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.67538</td>\n",
       "      <td>-25.13993</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>20</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Torgersen</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N10A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/16/07</td>\n",
       "      <td>46.0</td>\n",
       "      <td>21.5</td>\n",
       "      <td>194.0</td>\n",
       "      <td>4200.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>9.11616</td>\n",
       "      <td>-24.77227</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>338</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>119</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N38A1</td>\n",
       "      <td>No</td>\n",
       "      <td>12/1/09</td>\n",
       "      <td>47.2</td>\n",
       "      <td>13.7</td>\n",
       "      <td>214.0</td>\n",
       "      <td>4925.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>7.99184</td>\n",
       "      <td>-26.20538</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>340</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>121</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N39A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>46.8</td>\n",
       "      <td>14.3</td>\n",
       "      <td>215.0</td>\n",
       "      <td>4850.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.41151</td>\n",
       "      <td>-26.13832</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>341</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>122</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N39A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>50.4</td>\n",
       "      <td>15.7</td>\n",
       "      <td>222.0</td>\n",
       "      <td>5750.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.30166</td>\n",
       "      <td>-26.04117</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>342</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>123</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N43A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>45.2</td>\n",
       "      <td>14.8</td>\n",
       "      <td>212.0</td>\n",
       "      <td>5200.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.24246</td>\n",
       "      <td>-26.11969</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>343</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>124</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N43A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>49.9</td>\n",
       "      <td>16.1</td>\n",
       "      <td>213.0</td>\n",
       "      <td>5400.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.36390</td>\n",
       "      <td>-26.15531</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>242 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    studyName  Sample Number                              Species  Region  \\\n",
       "2     PAL0708              3  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "9     PAL0708             10  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "12    PAL0708             13  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "17    PAL0708             18  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "19    PAL0708             20  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "..        ...            ...                                  ...     ...   \n",
       "338   PAL0910            119    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "340   PAL0910            121    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "341   PAL0910            122    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "342   PAL0910            123    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "343   PAL0910            124    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "\n",
       "        Island               Stage Individual ID Clutch Completion  Date Egg  \\\n",
       "2    Torgersen  Adult, 1 Egg Stage          N2A1               Yes  11/16/07   \n",
       "9    Torgersen  Adult, 1 Egg Stage          N5A2               Yes   11/9/07   \n",
       "12   Torgersen  Adult, 1 Egg Stage          N7A1               Yes  11/15/07   \n",
       "17   Torgersen  Adult, 1 Egg Stage          N9A2               Yes  11/12/07   \n",
       "19   Torgersen  Adult, 1 Egg Stage         N10A2               Yes  11/16/07   \n",
       "..         ...                 ...           ...               ...       ...   \n",
       "338     Biscoe  Adult, 1 Egg Stage         N38A1                No   12/1/09   \n",
       "340     Biscoe  Adult, 1 Egg Stage         N39A1               Yes  11/22/09   \n",
       "341     Biscoe  Adult, 1 Egg Stage         N39A2               Yes  11/22/09   \n",
       "342     Biscoe  Adult, 1 Egg Stage         N43A1               Yes  11/22/09   \n",
       "343     Biscoe  Adult, 1 Egg Stage         N43A2               Yes  11/22/09   \n",
       "\n",
       "     Culmen Length (mm)  Culmen Depth (mm)  Flipper Length (mm)  \\\n",
       "2                  40.3               18.0                195.0   \n",
       "9                  42.0               20.2                190.0   \n",
       "12                 41.1               17.6                182.0   \n",
       "17                 42.5               20.7                197.0   \n",
       "19                 46.0               21.5                194.0   \n",
       "..                  ...                ...                  ...   \n",
       "338                47.2               13.7                214.0   \n",
       "340                46.8               14.3                215.0   \n",
       "341                50.4               15.7                222.0   \n",
       "342                45.2               14.8                212.0   \n",
       "343                49.9               16.1                213.0   \n",
       "\n",
       "     Body Mass (g)     Sex  Delta 15 N (o/oo)  Delta 13 C (o/oo)  \\\n",
       "2           3250.0  FEMALE            8.36821          -25.33302   \n",
       "9           4250.0     NaN            9.13362          -25.09368   \n",
       "12          3200.0  FEMALE                NaN                NaN   \n",
       "17          4500.0    MALE            8.67538          -25.13993   \n",
       "19          4200.0    MALE            9.11616          -24.77227   \n",
       "..             ...     ...                ...                ...   \n",
       "338         4925.0  FEMALE            7.99184          -26.20538   \n",
       "340         4850.0  FEMALE            8.41151          -26.13832   \n",
       "341         5750.0    MALE            8.30166          -26.04117   \n",
       "342         5200.0  FEMALE            8.24246          -26.11969   \n",
       "343         5400.0    MALE            8.36390          -26.15531   \n",
       "\n",
       "                                 Comments  \n",
       "2                                     NaN  \n",
       "9    No blood sample obtained for sexing.  \n",
       "12         Not enough blood for isotopes.  \n",
       "17                                    NaN  \n",
       "19                                    NaN  \n",
       "..                                    ...  \n",
       "338                                   NaN  \n",
       "340                                   NaN  \n",
       "341                                   NaN  \n",
       "342                                   NaN  \n",
       "343                                   NaN  \n",
       "\n",
       "[242 rows x 17 columns]"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.query('`Culmen Length (mm)` > 40')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "38c69c9d-3025-4e1e-9f10-e954f4ab0b36",
   "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>studyName</th>\n",
       "      <th>Sample Number</th>\n",
       "      <th>Species</th>\n",
       "      <th>Region</th>\n",
       "      <th>Island</th>\n",
       "      <th>Stage</th>\n",
       "      <th>Individual ID</th>\n",
       "      <th>Clutch Completion</th>\n",
       "      <th>Date Egg</th>\n",
       "      <th>Culmen Length (mm)</th>\n",
       "      <th>Culmen Depth (mm)</th>\n",
       "      <th>Flipper Length (mm)</th>\n",
       "      <th>Body Mass (g)</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Delta 15 N (o/oo)</th>\n",
       "      <th>Delta 13 C (o/oo)</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>27</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N17A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/12/07</td>\n",
       "      <td>40.6</td>\n",
       "      <td>18.6</td>\n",
       "      <td>183.0</td>\n",
       "      <td>3550.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.93997</td>\n",
       "      <td>-25.36288</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>28</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N17A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/12/07</td>\n",
       "      <td>40.5</td>\n",
       "      <td>17.9</td>\n",
       "      <td>187.0</td>\n",
       "      <td>3200.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.08138</td>\n",
       "      <td>-25.49448</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>30</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N18A2</td>\n",
       "      <td>No</td>\n",
       "      <td>11/10/07</td>\n",
       "      <td>40.5</td>\n",
       "      <td>18.9</td>\n",
       "      <td>180.0</td>\n",
       "      <td>3950.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.90027</td>\n",
       "      <td>-25.11609</td>\n",
       "      <td>Nest never observed with full clutch.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>PAL0809</td>\n",
       "      <td>52</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N21A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/6/08</td>\n",
       "      <td>40.1</td>\n",
       "      <td>18.9</td>\n",
       "      <td>188.0</td>\n",
       "      <td>4300.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.51362</td>\n",
       "      <td>-26.55602</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>PAL0809</td>\n",
       "      <td>54</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N22A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/9/08</td>\n",
       "      <td>42.0</td>\n",
       "      <td>19.5</td>\n",
       "      <td>200.0</td>\n",
       "      <td>4050.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.48095</td>\n",
       "      <td>-26.31460</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>338</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>119</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N38A1</td>\n",
       "      <td>No</td>\n",
       "      <td>12/1/09</td>\n",
       "      <td>47.2</td>\n",
       "      <td>13.7</td>\n",
       "      <td>214.0</td>\n",
       "      <td>4925.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>7.99184</td>\n",
       "      <td>-26.20538</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>340</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>121</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N39A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>46.8</td>\n",
       "      <td>14.3</td>\n",
       "      <td>215.0</td>\n",
       "      <td>4850.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.41151</td>\n",
       "      <td>-26.13832</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>341</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>122</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N39A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>50.4</td>\n",
       "      <td>15.7</td>\n",
       "      <td>222.0</td>\n",
       "      <td>5750.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.30166</td>\n",
       "      <td>-26.04117</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>342</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>123</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N43A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>45.2</td>\n",
       "      <td>14.8</td>\n",
       "      <td>212.0</td>\n",
       "      <td>5200.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.24246</td>\n",
       "      <td>-26.11969</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>343</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>124</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N43A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>49.9</td>\n",
       "      <td>16.1</td>\n",
       "      <td>213.0</td>\n",
       "      <td>5400.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.36390</td>\n",
       "      <td>-26.15531</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>139 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    studyName  Sample Number                              Species  Region  \\\n",
       "26    PAL0708             27  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "27    PAL0708             28  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "29    PAL0708             30  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "51    PAL0809             52  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "53    PAL0809             54  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "..        ...            ...                                  ...     ...   \n",
       "338   PAL0910            119    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "340   PAL0910            121    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "341   PAL0910            122    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "342   PAL0910            123    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "343   PAL0910            124    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "\n",
       "     Island               Stage Individual ID Clutch Completion  Date Egg  \\\n",
       "26   Biscoe  Adult, 1 Egg Stage         N17A1               Yes  11/12/07   \n",
       "27   Biscoe  Adult, 1 Egg Stage         N17A2               Yes  11/12/07   \n",
       "29   Biscoe  Adult, 1 Egg Stage         N18A2                No  11/10/07   \n",
       "51   Biscoe  Adult, 1 Egg Stage         N21A2               Yes   11/6/08   \n",
       "53   Biscoe  Adult, 1 Egg Stage         N22A2               Yes   11/9/08   \n",
       "..      ...                 ...           ...               ...       ...   \n",
       "338  Biscoe  Adult, 1 Egg Stage         N38A1                No   12/1/09   \n",
       "340  Biscoe  Adult, 1 Egg Stage         N39A1               Yes  11/22/09   \n",
       "341  Biscoe  Adult, 1 Egg Stage         N39A2               Yes  11/22/09   \n",
       "342  Biscoe  Adult, 1 Egg Stage         N43A1               Yes  11/22/09   \n",
       "343  Biscoe  Adult, 1 Egg Stage         N43A2               Yes  11/22/09   \n",
       "\n",
       "     Culmen Length (mm)  Culmen Depth (mm)  Flipper Length (mm)  \\\n",
       "26                 40.6               18.6                183.0   \n",
       "27                 40.5               17.9                187.0   \n",
       "29                 40.5               18.9                180.0   \n",
       "51                 40.1               18.9                188.0   \n",
       "53                 42.0               19.5                200.0   \n",
       "..                  ...                ...                  ...   \n",
       "338                47.2               13.7                214.0   \n",
       "340                46.8               14.3                215.0   \n",
       "341                50.4               15.7                222.0   \n",
       "342                45.2               14.8                212.0   \n",
       "343                49.9               16.1                213.0   \n",
       "\n",
       "     Body Mass (g)     Sex  Delta 15 N (o/oo)  Delta 13 C (o/oo)  \\\n",
       "26          3550.0    MALE            8.93997          -25.36288   \n",
       "27          3200.0  FEMALE            8.08138          -25.49448   \n",
       "29          3950.0    MALE            8.90027          -25.11609   \n",
       "51          4300.0    MALE            8.51362          -26.55602   \n",
       "53          4050.0    MALE            8.48095          -26.31460   \n",
       "..             ...     ...                ...                ...   \n",
       "338         4925.0  FEMALE            7.99184          -26.20538   \n",
       "340         4850.0  FEMALE            8.41151          -26.13832   \n",
       "341         5750.0    MALE            8.30166          -26.04117   \n",
       "342         5200.0  FEMALE            8.24246          -26.11969   \n",
       "343         5400.0    MALE            8.36390          -26.15531   \n",
       "\n",
       "                                  Comments  \n",
       "26                                     NaN  \n",
       "27                                     NaN  \n",
       "29   Nest never observed with full clutch.  \n",
       "51                                     NaN  \n",
       "53                                     NaN  \n",
       "..                                     ...  \n",
       "338                                    NaN  \n",
       "340                                    NaN  \n",
       "341                                    NaN  \n",
       "342                                    NaN  \n",
       "343                                    NaN  \n",
       "\n",
       "[139 rows x 17 columns]"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa[(dfa.Island == \"Biscoe\") & (dfa['Culmen Length (mm)'] > 40)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "afaeafbb-b336-4cc0-8bc5-7e10dc92fdf4",
   "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>studyName</th>\n",
       "      <th>Sample Number</th>\n",
       "      <th>Species</th>\n",
       "      <th>Region</th>\n",
       "      <th>Island</th>\n",
       "      <th>Stage</th>\n",
       "      <th>Individual ID</th>\n",
       "      <th>Clutch Completion</th>\n",
       "      <th>Date Egg</th>\n",
       "      <th>Culmen Length (mm)</th>\n",
       "      <th>Culmen Depth (mm)</th>\n",
       "      <th>Flipper Length (mm)</th>\n",
       "      <th>Body Mass (g)</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Delta 15 N (o/oo)</th>\n",
       "      <th>Delta 13 C (o/oo)</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>27</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N17A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/12/07</td>\n",
       "      <td>40.6</td>\n",
       "      <td>18.6</td>\n",
       "      <td>183.0</td>\n",
       "      <td>3550.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.93997</td>\n",
       "      <td>-25.36288</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>28</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N17A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/12/07</td>\n",
       "      <td>40.5</td>\n",
       "      <td>17.9</td>\n",
       "      <td>187.0</td>\n",
       "      <td>3200.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.08138</td>\n",
       "      <td>-25.49448</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>PAL0708</td>\n",
       "      <td>30</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N18A2</td>\n",
       "      <td>No</td>\n",
       "      <td>11/10/07</td>\n",
       "      <td>40.5</td>\n",
       "      <td>18.9</td>\n",
       "      <td>180.0</td>\n",
       "      <td>3950.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.90027</td>\n",
       "      <td>-25.11609</td>\n",
       "      <td>Nest never observed with full clutch.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>PAL0809</td>\n",
       "      <td>52</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N21A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/6/08</td>\n",
       "      <td>40.1</td>\n",
       "      <td>18.9</td>\n",
       "      <td>188.0</td>\n",
       "      <td>4300.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.51362</td>\n",
       "      <td>-26.55602</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>PAL0809</td>\n",
       "      <td>54</td>\n",
       "      <td>Adelie Penguin (Pygoscelis adeliae)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N22A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/9/08</td>\n",
       "      <td>42.0</td>\n",
       "      <td>19.5</td>\n",
       "      <td>200.0</td>\n",
       "      <td>4050.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.48095</td>\n",
       "      <td>-26.31460</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>338</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>119</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N38A1</td>\n",
       "      <td>No</td>\n",
       "      <td>12/1/09</td>\n",
       "      <td>47.2</td>\n",
       "      <td>13.7</td>\n",
       "      <td>214.0</td>\n",
       "      <td>4925.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>7.99184</td>\n",
       "      <td>-26.20538</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>340</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>121</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N39A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>46.8</td>\n",
       "      <td>14.3</td>\n",
       "      <td>215.0</td>\n",
       "      <td>4850.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.41151</td>\n",
       "      <td>-26.13832</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>341</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>122</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N39A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>50.4</td>\n",
       "      <td>15.7</td>\n",
       "      <td>222.0</td>\n",
       "      <td>5750.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.30166</td>\n",
       "      <td>-26.04117</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>342</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>123</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N43A1</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>45.2</td>\n",
       "      <td>14.8</td>\n",
       "      <td>212.0</td>\n",
       "      <td>5200.0</td>\n",
       "      <td>FEMALE</td>\n",
       "      <td>8.24246</td>\n",
       "      <td>-26.11969</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>343</th>\n",
       "      <td>PAL0910</td>\n",
       "      <td>124</td>\n",
       "      <td>Gentoo penguin (Pygoscelis papua)</td>\n",
       "      <td>Anvers</td>\n",
       "      <td>Biscoe</td>\n",
       "      <td>Adult, 1 Egg Stage</td>\n",
       "      <td>N43A2</td>\n",
       "      <td>Yes</td>\n",
       "      <td>11/22/09</td>\n",
       "      <td>49.9</td>\n",
       "      <td>16.1</td>\n",
       "      <td>213.0</td>\n",
       "      <td>5400.0</td>\n",
       "      <td>MALE</td>\n",
       "      <td>8.36390</td>\n",
       "      <td>-26.15531</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>139 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    studyName  Sample Number                              Species  Region  \\\n",
       "26    PAL0708             27  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "27    PAL0708             28  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "29    PAL0708             30  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "51    PAL0809             52  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "53    PAL0809             54  Adelie Penguin (Pygoscelis adeliae)  Anvers   \n",
       "..        ...            ...                                  ...     ...   \n",
       "338   PAL0910            119    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "340   PAL0910            121    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "341   PAL0910            122    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "342   PAL0910            123    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "343   PAL0910            124    Gentoo penguin (Pygoscelis papua)  Anvers   \n",
       "\n",
       "     Island               Stage Individual ID Clutch Completion  Date Egg  \\\n",
       "26   Biscoe  Adult, 1 Egg Stage         N17A1               Yes  11/12/07   \n",
       "27   Biscoe  Adult, 1 Egg Stage         N17A2               Yes  11/12/07   \n",
       "29   Biscoe  Adult, 1 Egg Stage         N18A2                No  11/10/07   \n",
       "51   Biscoe  Adult, 1 Egg Stage         N21A2               Yes   11/6/08   \n",
       "53   Biscoe  Adult, 1 Egg Stage         N22A2               Yes   11/9/08   \n",
       "..      ...                 ...           ...               ...       ...   \n",
       "338  Biscoe  Adult, 1 Egg Stage         N38A1                No   12/1/09   \n",
       "340  Biscoe  Adult, 1 Egg Stage         N39A1               Yes  11/22/09   \n",
       "341  Biscoe  Adult, 1 Egg Stage         N39A2               Yes  11/22/09   \n",
       "342  Biscoe  Adult, 1 Egg Stage         N43A1               Yes  11/22/09   \n",
       "343  Biscoe  Adult, 1 Egg Stage         N43A2               Yes  11/22/09   \n",
       "\n",
       "     Culmen Length (mm)  Culmen Depth (mm)  Flipper Length (mm)  \\\n",
       "26                 40.6               18.6                183.0   \n",
       "27                 40.5               17.9                187.0   \n",
       "29                 40.5               18.9                180.0   \n",
       "51                 40.1               18.9                188.0   \n",
       "53                 42.0               19.5                200.0   \n",
       "..                  ...                ...                  ...   \n",
       "338                47.2               13.7                214.0   \n",
       "340                46.8               14.3                215.0   \n",
       "341                50.4               15.7                222.0   \n",
       "342                45.2               14.8                212.0   \n",
       "343                49.9               16.1                213.0   \n",
       "\n",
       "     Body Mass (g)     Sex  Delta 15 N (o/oo)  Delta 13 C (o/oo)  \\\n",
       "26          3550.0    MALE            8.93997          -25.36288   \n",
       "27          3200.0  FEMALE            8.08138          -25.49448   \n",
       "29          3950.0    MALE            8.90027          -25.11609   \n",
       "51          4300.0    MALE            8.51362          -26.55602   \n",
       "53          4050.0    MALE            8.48095          -26.31460   \n",
       "..             ...     ...                ...                ...   \n",
       "338         4925.0  FEMALE            7.99184          -26.20538   \n",
       "340         4850.0  FEMALE            8.41151          -26.13832   \n",
       "341         5750.0    MALE            8.30166          -26.04117   \n",
       "342         5200.0  FEMALE            8.24246          -26.11969   \n",
       "343         5400.0    MALE            8.36390          -26.15531   \n",
       "\n",
       "                                  Comments  \n",
       "26                                     NaN  \n",
       "27                                     NaN  \n",
       "29   Nest never observed with full clutch.  \n",
       "51                                     NaN  \n",
       "53                                     NaN  \n",
       "..                                     ...  \n",
       "338                                    NaN  \n",
       "340                                    NaN  \n",
       "341                                    NaN  \n",
       "342                                    NaN  \n",
       "343                                    NaN  \n",
       "\n",
       "[139 rows x 17 columns]"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.query('Island == \"Biscoe\" & `Culmen Length (mm)` > 40')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "7e688f41-6538-4e50-a82d-d23e8e7edc47",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['Torgersen', 'Biscoe', 'Dream'], dtype=object)"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.Island.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "3e4d757f-4ea0-4efb-aa89-6091aebdddb8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Island\n",
       "Biscoe       168\n",
       "Dream        124\n",
       "Torgersen     52\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa['Island'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "c9455d79-06f5-41ad-952e-6f321d18d58e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Island\n",
       "Biscoe       45.257485\n",
       "Dream        44.167742\n",
       "Torgersen    38.950980\n",
       "Name: Culmen Length (mm), dtype: float64"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa.groupby('Island')['Culmen Length (mm)'].mean()"
   ]
  }
 ],
 "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.14.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
