From f344bea5bfbf622e92fc6200345b17eeb5a9de28 Mon Sep 17 00:00:00 2001 From: jnaiman Date: Thu, 2 Nov 2023 16:53:00 -0500 Subject: [PATCH] Auto-commit: Thu Nov 2 16:53:00 CDT 2023 --- week11/inClass_week11.ipynb | 190 +++++++++++++++++++++++++++--------- 1 file changed, 145 insertions(+), 45 deletions(-) diff --git a/week11/inClass_week11.ipynb b/week11/inClass_week11.ipynb index 4f9a0a9..96312f3 100644 --- a/week11/inClass_week11.ipynb +++ b/week11/inClass_week11.ipynb @@ -42,7 +42,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "ff18c909", + "id": "f56a6f9f", "metadata": {}, "outputs": [], "source": [ @@ -52,7 +52,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "d1fe32c6", + "id": "0def2e74", "metadata": {}, "outputs": [ { @@ -83,7 +83,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "e8d09c7c", + "id": "de515017", "metadata": {}, "outputs": [], "source": [ @@ -102,7 +102,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "ecb06cf3", + "id": "e30d017a", "metadata": {}, "outputs": [], "source": [ @@ -112,7 +112,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "ee2a256d", + "id": "8180dd4f", "metadata": {}, "outputs": [ { @@ -201,7 +201,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "11e210c6", + "id": "26aca538", "metadata": {}, "outputs": [], "source": [ @@ -213,7 +213,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "55246f56", + "id": "70a1a160", "metadata": {}, "outputs": [], "source": [ @@ -222,7 +222,7 @@ }, { "cell_type": "markdown", - "id": "5840341f", + "id": "625252df", "metadata": {}, "source": [ "## Use Altair to make the chart" @@ -231,7 +231,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "14a35c47", + "id": "6e1420a1", "metadata": {}, "outputs": [], "source": [ @@ -241,7 +241,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "f9b4bd25", + "id": "f89e2800", "metadata": {}, "outputs": [ { @@ -334,7 +334,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "28a80163", + "id": "b3c06763", "metadata": {}, "outputs": [ { @@ -428,7 +428,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "b74bea4f", + "id": "5f31df12", "metadata": {}, "outputs": [ { @@ -522,7 +522,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "77e2f314", + "id": "a798386d", "metadata": {}, "outputs": [ { @@ -617,7 +617,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "c0ab3d65", + "id": "3048cb98", "metadata": {}, "outputs": [ { @@ -712,7 +712,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "88f0720e", + "id": "ee4bac38", "metadata": {}, "outputs": [ { @@ -808,7 +808,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "dceccce6", + "id": "590c0e8c", "metadata": {}, "outputs": [], "source": [ @@ -817,7 +817,7 @@ }, { "cell_type": "markdown", - "id": "7295671f", + "id": "bfb50a53", "metadata": {}, "source": [ "```javascript\n", @@ -840,7 +840,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "f7a05222", + "id": "077097f6", "metadata": {}, "outputs": [ { @@ -935,7 +935,7 @@ }, { "cell_type": "markdown", - "id": "7e63b0b6", + "id": "9a703ba4", "metadata": {}, "source": [ "```javascript\n", @@ -955,7 +955,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "bdc21238", + "id": "f2736941", "metadata": {}, "outputs": [ { @@ -1048,7 +1048,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "715e7e84", + "id": "bb47d94d", "metadata": {}, "outputs": [ { @@ -1138,7 +1138,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "e622fbdb", + "id": "664f9973", "metadata": {}, "outputs": [ { @@ -1247,7 +1247,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "fbfbd9b1", + "id": "0bf725bc", "metadata": {}, "outputs": [], "source": [ @@ -1257,7 +1257,7 @@ { "cell_type": "code", "execution_count": 27, - "id": "9ccf2d1b", + "id": "86e3e125", "metadata": {}, "outputs": [ { @@ -1277,7 +1277,7 @@ }, { "cell_type": "markdown", - "id": "db9f2884", + "id": "dadcd97d", "metadata": {}, "source": [ "### Mobility dashboard with local dataset" @@ -1286,7 +1286,7 @@ { "cell_type": "code", "execution_count": 28, - "id": "0f4b13da", + "id": "5c9d8dc7", "metadata": {}, "outputs": [], "source": [ @@ -1297,7 +1297,7 @@ { "cell_type": "code", "execution_count": 29, - "id": "a7cd38f5", + "id": "be0a5b03", "metadata": {}, "outputs": [], "source": [ @@ -1307,7 +1307,7 @@ { "cell_type": "code", "execution_count": 30, - "id": "4cb1fcfb", + "id": "11288218", "metadata": {}, "outputs": [ { @@ -1524,7 +1524,7 @@ { "cell_type": "code", "execution_count": 31, - "id": "8260afb4", + "id": "89311e19", "metadata": {}, "outputs": [ { @@ -1641,7 +1641,7 @@ { "cell_type": "code", "execution_count": 32, - "id": "c73a707e", + "id": "f7f21293", "metadata": {}, "outputs": [], "source": [ @@ -1651,7 +1651,7 @@ { "cell_type": "code", "execution_count": 33, - "id": "a3cd4d58", + "id": "836db1fb", "metadata": {}, "outputs": [], "source": [ @@ -1661,7 +1661,7 @@ { "cell_type": "code", "execution_count": 35, - "id": "4aa05311", + "id": "b2ed5ec5", "metadata": {}, "outputs": [ { @@ -1682,7 +1682,7 @@ { "cell_type": "code", "execution_count": 36, - "id": "28bf67c8", + "id": "0a99f722", "metadata": {}, "outputs": [ { @@ -1702,7 +1702,7 @@ }, { "cell_type": "markdown", - "id": "e8b35c0a", + "id": "de830923", "metadata": {}, "source": [ "## Mobility dataset with dropdown selection for state" @@ -1711,7 +1711,7 @@ { "cell_type": "code", "execution_count": 40, - "id": "4c757449", + "id": "9a2290e7", "metadata": {}, "outputs": [ { @@ -1807,7 +1807,7 @@ { "cell_type": "code", "execution_count": 44, - "id": "0788ae75", + "id": "7d7df191", "metadata": {}, "outputs": [ { @@ -1906,7 +1906,7 @@ { "cell_type": "code", "execution_count": 46, - "id": "20c1b302", + "id": "8b0d6b02", "metadata": {}, "outputs": [ { @@ -2029,7 +2029,7 @@ { "cell_type": "code", "execution_count": 47, - "id": "72545048", + "id": "bc48f289", "metadata": {}, "outputs": [ { @@ -2054,7 +2054,7 @@ { "cell_type": "code", "execution_count": 48, - "id": "f26aeb7c", + "id": "694c1c19", "metadata": {}, "outputs": [], "source": [ @@ -2064,7 +2064,7 @@ { "cell_type": "code", "execution_count": 53, - "id": "483b07f2", + "id": "8290aba2", "metadata": {}, "outputs": [ { @@ -2196,7 +2196,7 @@ { "cell_type": "code", "execution_count": 54, - "id": "a9c0d455", + "id": "4cd397ea", "metadata": {}, "outputs": [ { @@ -2316,7 +2316,7 @@ { "cell_type": "code", "execution_count": 55, - "id": "c4c01a02", + "id": "59bd7e7d", "metadata": {}, "outputs": [ { @@ -2427,7 +2427,7 @@ { "cell_type": "code", "execution_count": 57, - "id": "0ab1c334", + "id": "1352367c", "metadata": {}, "outputs": [ { @@ -2527,7 +2527,7 @@ { "cell_type": "code", "execution_count": 59, - "id": "febe3a6b", + "id": "b0d60428", "metadata": {}, "outputs": [ { @@ -2635,10 +2635,110 @@ "chart1" ] }, + { + "cell_type": "code", + "execution_count": 60, + "id": "0deb7583", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + "
\n", + "" + ], + "text/plain": [ + "alt.Chart(...)" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chart1 = alt.Chart(mobility_url).transform_calculate(\n", + "# log_pop = 'log(datum.Population)/log(10)'\n", + " log_pop = 'log(datum[\"Population\"])/log(10)'\n", + ").mark_rect().encode(\n", + " alt.Y(\"Student_teacher_ratio:Q\", bin=alt.Bin(maxbins=10)),\n", + " #alt.Y(\"Population:Q\", bin=alt.Bin(maxbins=50), scale=alt.Scale(type='log')),\n", + " alt.X(\"log_pop:Q\", bin=alt.Bin(maxbins=50), title='log(Population)'),\n", + " alt.Color(\"count()\")\n", + ").properties(\n", + " height=300\n", + ").interactive()\n", + "chart1" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "1cd9a28a", + "id": "59b5d4dd", "metadata": {}, "outputs": [], "source": []