{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [ "remove-cell" ] }, "outputs": [], "source": [ "import sys\n", "import os\n", "if not any(path.endswith('textbook') for path in sys.path):\n", " sys.path.append(os.path.abspath('../../..'))\n", "from textbook_utils import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "tags": [ "remove-cell" ] }, "outputs": [], "source": [ "dogs = pd.read_csv('dogs.csv')" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "(ch:sql)=\n", "# Working with Relations Using SQL" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "In {ref}`ch:pandas`, we used dataframes to represent tables of data. This chapter introduces\n", "*relations*, another widely used way to represent data tables. We\n", "also introduce SQL, the standard programming language for working with\n", "relations. Here's an example of a relation that holds information about\n", "popular dog breeds:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "tags": [ "remove-cell" ] }, "outputs": [ { "data": { "text/html": [ "
breed | \n", "grooming | \n", "food_cost | \n", "kids | \n", "size | \n", "
---|---|---|---|---|
Labrador Retriever | \n", "weekly | \n", "466.0 | \n", "high | \n", "medium | \n", "
German Shepherd | \n", "weekly | \n", "466.0 | \n", "medium | \n", "large | \n", "
Beagle | \n", "daily | \n", "324.0 | \n", "high | \n", "small | \n", "
Golden Retriever | \n", "weekly | \n", "466.0 | \n", "high | \n", "medium | \n", "
Yorkshire Terrier | \n", "daily | \n", "324.0 | \n", "low | \n", "small | \n", "
Bulldog | \n", "weekly | \n", "466.0 | \n", "medium | \n", "medium | \n", "
Boxer | \n", "weekly | \n", "466.0 | \n", "high | \n", "medium | \n", "