diff --git a/01 - Getting Started.ipynb b/01 - Getting Started.ipynb index 33cebd9..f7d4ff1 100644 --- a/01 - Getting Started.ipynb +++ b/01 - Getting Started.ipynb @@ -947,18 +947,28 @@ "### Exercise 4\n", "\n", "Add a new column to the `penguins` table with the mean mass of penguins found\n", - "on that island.\n", - "\n", - "```python\n", + "on that island." + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ "mean_mass_per_island = (\n", " penguins\n", " .group_by(\"island\")\n", " .agg(island_mean_mass=penguins.body_mass_g.mean())\n", ")\n", "\n", - "penguins.join(...) # what goes here?\n", - "```\n", - "\n", + "penguins.join(...) # what goes here?" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "#### Solution" ] }, diff --git a/03 - Switching Backends.ipynb b/03 - Switching Backends.ipynb index 69b3c97..f279156 100644 --- a/03 - Switching Backends.ipynb +++ b/03 - Switching Backends.ipynb @@ -75,7 +75,9 @@ "source": [ "basics = con.read_parquet(\n", " \"data/imdb/imdb_title_basics_sample_5.parquet\", table_name=\"imdb_title_basics\"\n", - ")" + ")\n", + "\n", + "basics" ], "execution_count": null, "outputs": [] @@ -86,7 +88,9 @@ "source": [ "ratings = con.read_parquet(\n", " \"data/imdb/imdb_title_ratings.parquet\", table_name=\"imdb_title_ratings\"\n", - ")" + ")\n", + "\n", + "ratings" ], "execution_count": null, "outputs": [] diff --git a/quarto/01 - Getting Started.qmd b/quarto/01 - Getting Started.qmd index b601ecf..abebeea 100644 --- a/quarto/01 - Getting Started.qmd +++ b/quarto/01 - Getting Started.qmd @@ -493,7 +493,7 @@ left.join(right, "key_column_name") Add a new column to the `penguins` table with the mean mass of penguins found on that island. -```python +```{python} mean_mass_per_island = ( penguins .group_by("island") diff --git a/quarto/03 - Switching Backends.qmd b/quarto/03 - Switching Backends.qmd index 2d2a254..89edab5 100644 --- a/quarto/03 - Switching Backends.qmd +++ b/quarto/03 - Switching Backends.qmd @@ -51,12 +51,16 @@ con = ibis.duckdb.connect() basics = con.read_parquet( "data/imdb/imdb_title_basics_sample_5.parquet", table_name="imdb_title_basics" ) + +basics ``` ```{python} ratings = con.read_parquet( "data/imdb/imdb_title_ratings.parquet", table_name="imdb_title_ratings" ) + +ratings ``` ## Exercises diff --git a/solutions/nb01_ex04.py b/solutions/nb01_ex04.py index fd8cec0..0d270b8 100644 --- a/solutions/nb01_ex04.py +++ b/solutions/nb01_ex04.py @@ -1,6 +1,7 @@ -( +mean_mass_per_island = ( penguins .group_by("island") .agg(island_mean_mass=penguins.body_mass_g.mean()) - .join(penguins, "island") ) + +penguins.join(mean_mass_per_island, "island")