diff --git a/experiments/duckdb_census_of_population.ipynb b/experiments/duckdb_census_of_population.ipynb index e9881f6..4387db4 100644 --- a/experiments/duckdb_census_of_population.ipynb +++ b/experiments/duckdb_census_of_population.ipynb @@ -2,28 +2,19 @@ "cells": [ { "cell_type": "code", - "execution_count": 36, + "execution_count": 40, "id": "56ac906e", "metadata": {}, "outputs": [], "source": [ - "import buckaroo\n", "import duckdb\n", - "from IPython.core.interactiveshell import InteractiveShell\n", - "from lonboard import viz\n", - "import pandas as pd\n", - "\n", - "# Enable multiple outputs per cell\n", - "InteractiveShell.ast_node_interactivity = \"all\"\n", - "# Show all columns\n", - "pd.set_option('display.max_columns', None)\n", "\n", "output_data_folder = '/data/experiments'" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 41, "id": "708e293d", "metadata": {}, "outputs": [], @@ -44,17 +35,31 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 42, "id": "580c82ad-f64d-439f-9055-2307fdf7cccd", "metadata": {}, "outputs": [ { "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8c53af935cf44664a8b493f5133b87e7", + "version_major": 2, + "version_minor": 0 + }, "text/plain": [ - "" + "FloatProgress(value=0.0, layout=Layout(width='auto'), style=ProgressStyle(bar_color='black'))" ] }, - "execution_count": 28, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -63,10 +68,19 @@ "con.execute(\"\"\"\n", "DROP TABLE IF EXISTS geo_data;\n", "CREATE TABLE geo_data AS\n", - "SELECT geo.da_dguid, cop.count_total_4, CAST(round((cop.count_total_1 / (ST_Area_Spheroid(geo.geom) / 1000000.0)), 0) AS INTEGER) AS count_total_4_per_square_km, geo.geom \n", - "FROM 'https://data.dataforcanada.org/processed/statistics_canada/census_of_population/2021/tabular/da_2021.parquet' AS cop,\n", - "'https://data.dataforcanada.org/processed/statistics_canada/boundaries/2021/digital_boundary_files/da_2021.parquet' AS geo\n", - "WHERE geo.csd_name in ('Ottawa') AND cop.da_dguid = geo.da_dguid;\n", + "SELECT\n", + " geo.da_dguid,\n", + " cop.count_total_4,\n", + " CAST(\n", + " ROUND(\n", + " (cop.count_total_1 / (ST_AREA_SPHEROID(geo.geom) / 1000000.0)), 0\n", + " ) AS INTEGER\n", + " ) AS count_total_4_per_square_km,\n", + " geo.geom\n", + "FROM\n", + " 'https://data.dataforcanada.org/processed/statistics_canada/census_of_population/2021/tabular/da_2021.parquet' AS cop,\n", + " 'https://data.dataforcanada.org/processed/statistics_canada/boundaries/2021/digital_boundary_files/da_2021.parquet' AS geo\n", + "WHERE geo.csd_name IN ('Ottawa') AND cop.da_dguid = geo.da_dguid;\n", "\"\"\")" ] }, @@ -80,17 +94,17 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 43, "id": "0528eeb4-fb89-4640-94c6-c0eda4cbe764", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 37, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" }