From f891011a5a1133229024a7051205b59027894546 Mon Sep 17 00:00:00 2001 From: Solange Emmenegger <solange.emmenegger@hslu.ch> Date: Mon, 24 Oct 2022 14:37:36 +0000 Subject: [PATCH] Auto-saving for solange.emmenegger@hslu.ch on branch master from commit a4710a6 --- .../00a Python Self Study.ipynb | 6 +- .../00b Python Exercises.ipynb | 1126 ++++++++-------- .../00c Pandas Exercises.ipynb | 1181 +++++------------ 3 files changed, 936 insertions(+), 1377 deletions(-) diff --git a/notebooks/00 Python Tutorial/00a Python Self Study.ipynb b/notebooks/00 Python Tutorial/00a Python Self Study.ipynb index a95ced6..32534c6 100644 --- a/notebooks/00 Python Tutorial/00a Python Self Study.ipynb +++ b/notebooks/00 Python Tutorial/00a Python Self Study.ipynb @@ -3677,7 +3677,7 @@ } }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -3691,9 +3691,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" + "version": "3.9.12" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/notebooks/00 Python Tutorial/00b Python Exercises.ipynb b/notebooks/00 Python Tutorial/00b Python Exercises.ipynb index bf18786..bae9a85 100644 --- a/notebooks/00 Python Tutorial/00b Python Exercises.ipynb +++ b/notebooks/00 Python Tutorial/00b Python Exercises.ipynb @@ -24,21 +24,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 63, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World!\n" - ] - } - ], + "outputs": [], "source": [ "print(\"Hello World!\")" ] @@ -55,26 +58,30 @@ "execution_count": null, "metadata": { "solution2": "hidden", - "solution2_first": true + "solution2_first": true, + "tags": [] }, "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 64, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World!\n" - ] - } - ], + "outputs": [], "source": [ "def hello():\n", " print(\"Hello World!\")\n", @@ -98,22 +105,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 65, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World!\n", - "None\n" - ] - } - ], + "outputs": [], "source": [ "return_value = hello()\n", "print(return_value)" @@ -137,21 +146,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 66, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World!\n" - ] - } - ], + "outputs": [], "source": [ "def hello():\n", " return \"Hello World!\"\n", @@ -175,21 +187,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 67, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World!\n" - ] - } - ], + "outputs": [], "source": [ "def hello(output):\n", " print(output)\n", @@ -213,21 +228,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 68, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World!\n" - ] - } - ], + "outputs": [], "source": [ "def hello(output=\"Hello World!\"):\n", " print(output)\n", @@ -251,25 +269,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 69, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World!\n", - "Hello World!\n", - "Hello World!\n", - "Hello World!\n", - "Hello World!\n" - ] - } - ], + "outputs": [], "source": [ "# the _ variable is used by convention as a placeholder for a throwaway variable\n", "# we can use it here since we don't need the numbers 0 to 4 that we loop over\n", @@ -286,7 +303,7 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -303,25 +320,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 71, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 print\n", - "2 this\n", - "3 element\n", - "4 by\n", - "5 ellement\n" - ] - } - ], + "outputs": [], "source": [ "for i, elem in enumerate(data):\n", " print(i+1, elem)\n", @@ -352,11 +368,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 72, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -380,24 +407,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 73, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "[2, 4, 6, 8, 10]" - ] - }, - "execution_count": 73, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "even_ints[0:5]" ] @@ -419,24 +446,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 74, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "[12, 14, 16, 18, 20, 22, 24, 26, 28, 30]" - ] - }, - "execution_count": 74, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "even_ints[5:15]" ] @@ -458,24 +485,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 75, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "[92, 94, 96, 98, 100]" - ] - }, - "execution_count": 75, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "even_ints[-5:]" ] @@ -497,48 +524,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 76, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "[4,\n", - " 8,\n", - " 12,\n", - " 16,\n", - " 20,\n", - " 24,\n", - " 28,\n", - " 32,\n", - " 36,\n", - " 40,\n", - " 44,\n", - " 48,\n", - " 52,\n", - " 56,\n", - " 60,\n", - " 64,\n", - " 68,\n", - " 72,\n", - " 76,\n", - " 80,\n", - " 84,\n", - " 88,\n", - " 92,\n", - " 96,\n", - " 100]" - ] - }, - "execution_count": 76, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "even_ints[1::2]" ] @@ -560,73 +563,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 77, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "[100,\n", - " 98,\n", - " 96,\n", - " 94,\n", - " 92,\n", - " 90,\n", - " 88,\n", - " 86,\n", - " 84,\n", - " 82,\n", - " 80,\n", - " 78,\n", - " 76,\n", - " 74,\n", - " 72,\n", - " 70,\n", - " 68,\n", - " 66,\n", - " 64,\n", - " 62,\n", - " 60,\n", - " 58,\n", - " 56,\n", - " 54,\n", - " 52,\n", - " 50,\n", - " 48,\n", - " 46,\n", - " 44,\n", - " 42,\n", - " 40,\n", - " 38,\n", - " 36,\n", - " 34,\n", - " 32,\n", - " 30,\n", - " 28,\n", - " 26,\n", - " 24,\n", - " 22,\n", - " 20,\n", - " 18,\n", - " 16,\n", - " 14,\n", - " 12,\n", - " 10,\n", - " 8,\n", - " 6,\n", - " 4,\n", - " 2]" - ] - }, - "execution_count": 77, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "even_ints[::-1]" ] @@ -648,24 +602,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 78, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "'!dlroW olleH'" - ] - }, - "execution_count": 78, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "\"Hello World!\"[::-1] # strings can be treated as lists because they implement the iterator inteface" ] @@ -679,7 +633,7 @@ }, { "cell_type": "code", - "execution_count": 79, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -696,24 +650,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 80, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 2, 3, 4, 5]" - ] - }, - "execution_count": 80, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "a.append(5)\n", "a" @@ -736,24 +690,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 81, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 2, 3, 4, 5, 6, 7, 8]" - ] - }, - "execution_count": 81, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "a.extend([6,7,8])\n", "a" @@ -776,24 +730,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 82, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" - ] - }, - "execution_count": 82, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "a = a + [9,10]\n", "a" @@ -818,44 +772,44 @@ }, { "cell_type": "code", - "execution_count": 83, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, + { + "cell_type": "code", + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 83, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "5 in a" ] }, { "cell_type": "code", - "execution_count": 84, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "False" - ] - }, - "execution_count": 84, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "11 in a" ] @@ -877,24 +831,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 85, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]" - ] - }, - "execution_count": 85, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "[elem*2 for elem in a]" ] @@ -911,29 +865,30 @@ "execution_count": null, "metadata": { "solution2": "hidden", - "solution2_first": true + "solution2_first": true, + "tags": [] }, "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 86, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "['2', '4', '6', '8', '10']" - ] - }, - "execution_count": 86, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "[str(i) for i in a if i%2==0]" ] @@ -955,24 +910,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 87, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "(1, 2, 3)" - ] - }, - "execution_count": 87, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "a = (1,2,3)\n", "a" @@ -995,25 +950,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 88, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "ename": "TypeError", - "evalue": "'tuple' object does not support item assignment", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-88-7d02990d0abc>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ma\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment" - ] - } - ], + "outputs": [], "source": [ "a[0] = 0" ] @@ -1035,24 +989,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 89, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "{1, 2, 3, 4, 5}" - ] - }, - "execution_count": 89, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "a = set((1,1,2,2,3,4,5))\n", "a" @@ -1084,24 +1038,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 90, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'a': 1, 2: '2', 16: [3, 4, 5]}" - ] - }, - "execution_count": 90, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "d = {'a':1, 2:'2', 16:[3,4,5]}\n", "d" @@ -1124,24 +1078,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 91, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "'2'" - ] - }, - "execution_count": 91, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "d[2]" ] @@ -1158,29 +1112,30 @@ "execution_count": null, "metadata": { "solution2": "hidden", - "solution2_first": true + "solution2_first": true, + "tags": [] }, "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 92, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'a': 1, 2: '2'}" - ] - }, - "execution_count": 92, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "del d[16]\n", "d" @@ -1203,24 +1158,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 93, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "{'a': 1, 2: '2', 42: 42}" - ] - }, - "execution_count": 93, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "d[42] = 42\n", "d" @@ -1243,24 +1198,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 94, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "['1', '2', '42']" - ] - }, - "execution_count": 94, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "[str(d[i]) for i in d.keys()]" ] @@ -1282,25 +1237,25 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 95, + "execution_count": null, "metadata": { "code_folding": [], - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "{1: 'a', '2': 2, 42: 42}" - ] - }, - "execution_count": 95, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "{v:k for k, v in d.items()}\n", "\n", @@ -1328,11 +1283,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1356,11 +1322,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1384,11 +1361,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1421,11 +1409,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1458,11 +1457,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1481,7 +1491,7 @@ }, { "cell_type": "code", - "execution_count": 101, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1498,24 +1508,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 107, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "(2, 1)" - ] - }, - "execution_count": 107, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "def divide(dividend, divisor):\n", " return floor(dividend/divisor), dividend%divisor\n", @@ -1540,11 +1550,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1626,11 +1647,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1685,11 +1717,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1718,14 +1761,32 @@ " ..." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { + "jupyter": { + "source_hidden": true + }, "run_control": { "marked": false }, - "solution2": "hidden" + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1747,7 +1808,7 @@ }, { "cell_type": "code", - "execution_count": 110, + "execution_count": null, "metadata": { "solution2": "hidden", "solution2_first": true @@ -1763,9 +1824,27 @@ }, { "cell_type": "code", - "execution_count": 111, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, + { + "cell_type": "code", + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1782,20 +1861,9 @@ }, { "cell_type": "code", - "execution_count": 112, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]" - ] - }, - "execution_count": 112, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "fib(10)" ] @@ -1811,7 +1879,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1825,9 +1893,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" + "version": "3.9.12" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/notebooks/00 Python Tutorial/00c Pandas Exercises.ipynb b/notebooks/00 Python Tutorial/00c Pandas Exercises.ipynb index fa86936..1cbd75d 100644 --- a/notebooks/00 Python Tutorial/00c Pandas Exercises.ipynb +++ b/notebooks/00 Python Tutorial/00c Pandas Exercises.ipynb @@ -31,11 +31,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -52,7 +63,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { "solution2": "hidden", "solution2_first": true @@ -64,9 +75,27 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, + { + "cell_type": "code", + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -91,24 +120,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "(1000, 12)" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df.shape" ] @@ -131,258 +160,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "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>Rank</th>\n", - " <th>Title</th>\n", - " <th>Genre</th>\n", - " <th>Description</th>\n", - " <th>Director</th>\n", - " <th>Actors</th>\n", - " <th>Year</th>\n", - " <th>Runtime (Minutes)</th>\n", - " <th>Rating</th>\n", - " <th>Votes</th>\n", - " <th>Revenue (Millions)</th>\n", - " <th>Metascore</th>\n", - " </tr>\n", - " </thead>\n", - " <tbody>\n", - " <tr>\n", - " <th>0</th>\n", - " <td>1</td>\n", - " <td>Guardians of the Galaxy</td>\n", - " <td>Action,Adventure,Sci-Fi</td>\n", - " <td>A group of intergalactic criminals are forced ...</td>\n", - " <td>James Gunn</td>\n", - " <td>Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...</td>\n", - " <td>2014</td>\n", - " <td>121</td>\n", - " <td>8.1</td>\n", - " <td>757074</td>\n", - " <td>333.13</td>\n", - " <td>76.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>1</th>\n", - " <td>2</td>\n", - " <td>Prometheus</td>\n", - " <td>Adventure,Mystery,Sci-Fi</td>\n", - " <td>Following clues to the origin of mankind, a te...</td>\n", - " <td>Ridley Scott</td>\n", - " <td>Noomi Rapace, Logan Marshall-Green, Michael Fa...</td>\n", - " <td>2012</td>\n", - " <td>124</td>\n", - " <td>7.0</td>\n", - " <td>485820</td>\n", - " <td>126.46</td>\n", - " <td>65.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>2</th>\n", - " <td>3</td>\n", - " <td>Split</td>\n", - " <td>Horror,Thriller</td>\n", - " <td>Three girls are kidnapped by a man with a diag...</td>\n", - " <td>M. Night Shyamalan</td>\n", - " <td>James McAvoy, Anya Taylor-Joy, Haley Lu Richar...</td>\n", - " <td>2016</td>\n", - " <td>117</td>\n", - " <td>7.3</td>\n", - " <td>157606</td>\n", - " <td>138.12</td>\n", - " <td>62.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>3</th>\n", - " <td>4</td>\n", - " <td>Sing</td>\n", - " <td>Animation,Comedy,Family</td>\n", - " <td>In a city of humanoid animals, a hustling thea...</td>\n", - " <td>Christophe Lourdelet</td>\n", - " <td>Matthew McConaughey,Reese Witherspoon, Seth Ma...</td>\n", - " <td>2016</td>\n", - " <td>108</td>\n", - " <td>7.2</td>\n", - " <td>60545</td>\n", - " <td>270.32</td>\n", - " <td>59.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>4</th>\n", - " <td>5</td>\n", - " <td>Suicide Squad</td>\n", - " <td>Action,Adventure,Fantasy</td>\n", - " <td>A secret government agency recruits some of th...</td>\n", - " <td>David Ayer</td>\n", - " <td>Will Smith, Jared Leto, Margot Robbie, Viola D...</td>\n", - " <td>2016</td>\n", - " <td>123</td>\n", - " <td>6.2</td>\n", - " <td>393727</td>\n", - " <td>325.02</td>\n", - " <td>40.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>5</th>\n", - " <td>6</td>\n", - " <td>The Great Wall</td>\n", - " <td>Action,Adventure,Fantasy</td>\n", - " <td>European mercenaries searching for black powde...</td>\n", - " <td>Yimou Zhang</td>\n", - " <td>Matt Damon, Tian Jing, Willem Dafoe, Andy Lau</td>\n", - " <td>2016</td>\n", - " <td>103</td>\n", - " <td>6.1</td>\n", - " <td>56036</td>\n", - " <td>45.13</td>\n", - " <td>42.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>6</th>\n", - " <td>7</td>\n", - " <td>La La Land</td>\n", - " <td>Comedy,Drama,Music</td>\n", - " <td>A jazz pianist falls for an aspiring actress i...</td>\n", - " <td>Damien Chazelle</td>\n", - " <td>Ryan Gosling, Emma Stone, Rosemarie DeWitt, J....</td>\n", - " <td>2016</td>\n", - " <td>128</td>\n", - " <td>8.3</td>\n", - " <td>258682</td>\n", - " <td>151.06</td>\n", - " <td>93.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>7</th>\n", - " <td>8</td>\n", - " <td>Mindhorn</td>\n", - " <td>Comedy</td>\n", - " <td>A has-been actor best known for playing the ti...</td>\n", - " <td>Sean Foley</td>\n", - " <td>Essie Davis, Andrea Riseborough, Julian Barrat...</td>\n", - " <td>2016</td>\n", - " <td>89</td>\n", - " <td>6.4</td>\n", - " <td>2490</td>\n", - " <td>NaN</td>\n", - " <td>71.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>8</th>\n", - " <td>9</td>\n", - " <td>The Lost City of Z</td>\n", - " <td>Action,Adventure,Biography</td>\n", - " <td>A true-life drama, centering on British explor...</td>\n", - " <td>James Gray</td>\n", - " <td>Charlie Hunnam, Robert Pattinson, Sienna Mille...</td>\n", - " <td>2016</td>\n", - " <td>141</td>\n", - " <td>7.1</td>\n", - " <td>7188</td>\n", - " <td>8.01</td>\n", - " <td>78.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>9</th>\n", - " <td>10</td>\n", - " <td>Passengers</td>\n", - " <td>Adventure,Drama,Romance</td>\n", - " <td>A spacecraft traveling to a distant colony pla...</td>\n", - " <td>Morten Tyldum</td>\n", - " <td>Jennifer Lawrence, Chris Pratt, Michael Sheen,...</td>\n", - " <td>2016</td>\n", - " <td>116</td>\n", - " <td>7.0</td>\n", - " <td>192177</td>\n", - " <td>100.01</td>\n", - " <td>41.0</td>\n", - " </tr>\n", - " </tbody>\n", - "</table>\n", - "</div>" - ], - "text/plain": [ - " Rank Title Genre \\\n", - "0 1 Guardians of the Galaxy Action,Adventure,Sci-Fi \n", - "1 2 Prometheus Adventure,Mystery,Sci-Fi \n", - "2 3 Split Horror,Thriller \n", - "3 4 Sing Animation,Comedy,Family \n", - "4 5 Suicide Squad Action,Adventure,Fantasy \n", - "5 6 The Great Wall Action,Adventure,Fantasy \n", - "6 7 La La Land Comedy,Drama,Music \n", - "7 8 Mindhorn Comedy \n", - "8 9 The Lost City of Z Action,Adventure,Biography \n", - "9 10 Passengers Adventure,Drama,Romance \n", - "\n", - " Description Director \\\n", - "0 A group of intergalactic criminals are forced ... James Gunn \n", - "1 Following clues to the origin of mankind, a te... Ridley Scott \n", - "2 Three girls are kidnapped by a man with a diag... M. Night Shyamalan \n", - "3 In a city of humanoid animals, a hustling thea... Christophe Lourdelet \n", - "4 A secret government agency recruits some of th... David Ayer \n", - "5 European mercenaries searching for black powde... Yimou Zhang \n", - "6 A jazz pianist falls for an aspiring actress i... Damien Chazelle \n", - "7 A has-been actor best known for playing the ti... Sean Foley \n", - "8 A true-life drama, centering on British explor... James Gray \n", - "9 A spacecraft traveling to a distant colony pla... Morten Tyldum \n", - "\n", - " Actors Year Runtime (Minutes) \\\n", - "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 121 \n", - "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 124 \n", - "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 117 \n", - "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 108 \n", - "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 123 \n", - "5 Matt Damon, Tian Jing, Willem Dafoe, Andy Lau 2016 103 \n", - "6 Ryan Gosling, Emma Stone, Rosemarie DeWitt, J.... 2016 128 \n", - "7 Essie Davis, Andrea Riseborough, Julian Barrat... 2016 89 \n", - "8 Charlie Hunnam, Robert Pattinson, Sienna Mille... 2016 141 \n", - "9 Jennifer Lawrence, Chris Pratt, Michael Sheen,... 2016 116 \n", - "\n", - " Rating Votes Revenue (Millions) Metascore \n", - "0 8.1 757074 333.13 76.0 \n", - "1 7.0 485820 126.46 65.0 \n", - "2 7.3 157606 138.12 62.0 \n", - "3 7.2 60545 270.32 59.0 \n", - "4 6.2 393727 325.02 40.0 \n", - "5 6.1 56036 45.13 42.0 \n", - "6 8.3 258682 151.06 93.0 \n", - "7 6.4 2490 NaN 71.0 \n", - "8 7.1 7188 8.01 78.0 \n", - "9 7.0 192177 100.01 41.0 " - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df.head(n=10)" ] @@ -400,168 +195,30 @@ "metadata": { "lines_to_next_cell": 2, "solution2": "hidden", - "solution2_first": true + "solution2_first": true, + "tags": [] }, "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "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>Rank</th>\n", - " <th>Title</th>\n", - " <th>Genre</th>\n", - " <th>Description</th>\n", - " <th>Director</th>\n", - " <th>Actors</th>\n", - " <th>Year</th>\n", - " <th>Runtime (Minutes)</th>\n", - " <th>Rating</th>\n", - " <th>Votes</th>\n", - " <th>Revenue (Millions)</th>\n", - " <th>Metascore</th>\n", - " </tr>\n", - " </thead>\n", - " <tbody>\n", - " <tr>\n", - " <th>995</th>\n", - " <td>996</td>\n", - " <td>Secret in Their Eyes</td>\n", - " <td>Crime,Drama,Mystery</td>\n", - " <td>A tight-knit team of rising investigators, alo...</td>\n", - " <td>Billy Ray</td>\n", - " <td>Chiwetel Ejiofor, Nicole Kidman, Julia Roberts...</td>\n", - " <td>2015</td>\n", - " <td>111</td>\n", - " <td>6.2</td>\n", - " <td>27585</td>\n", - " <td>NaN</td>\n", - " <td>45.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>996</th>\n", - " <td>997</td>\n", - " <td>Hostel: Part II</td>\n", - " <td>Horror</td>\n", - " <td>Three American college students studying abroa...</td>\n", - " <td>Eli Roth</td>\n", - " <td>Lauren German, Heather Matarazzo, Bijou Philli...</td>\n", - " <td>2007</td>\n", - " <td>94</td>\n", - " <td>5.5</td>\n", - " <td>73152</td>\n", - " <td>17.54</td>\n", - " <td>46.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>997</th>\n", - " <td>998</td>\n", - " <td>Step Up 2: The Streets</td>\n", - " <td>Drama,Music,Romance</td>\n", - " <td>Romantic sparks occur between two dance studen...</td>\n", - " <td>Jon M. Chu</td>\n", - " <td>Robert Hoffman, Briana Evigan, Cassie Ventura,...</td>\n", - " <td>2008</td>\n", - " <td>98</td>\n", - " <td>6.2</td>\n", - " <td>70699</td>\n", - " <td>58.01</td>\n", - " <td>50.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>998</th>\n", - " <td>999</td>\n", - " <td>Search Party</td>\n", - " <td>Adventure,Comedy</td>\n", - " <td>A pair of friends embark on a mission to reuni...</td>\n", - " <td>Scot Armstrong</td>\n", - " <td>Adam Pally, T.J. Miller, Thomas Middleditch,Sh...</td>\n", - " <td>2014</td>\n", - " <td>93</td>\n", - " <td>5.6</td>\n", - " <td>4881</td>\n", - " <td>NaN</td>\n", - " <td>22.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>999</th>\n", - " <td>1000</td>\n", - " <td>Nine Lives</td>\n", - " <td>Comedy,Family,Fantasy</td>\n", - " <td>A stuffy businessman finds himself trapped ins...</td>\n", - " <td>Barry Sonnenfeld</td>\n", - " <td>Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...</td>\n", - " <td>2016</td>\n", - " <td>87</td>\n", - " <td>5.3</td>\n", - " <td>12435</td>\n", - " <td>19.64</td>\n", - " <td>11.0</td>\n", - " </tr>\n", - " </tbody>\n", - "</table>\n", - "</div>" - ], - "text/plain": [ - " Rank Title Genre \\\n", - "995 996 Secret in Their Eyes Crime,Drama,Mystery \n", - "996 997 Hostel: Part II Horror \n", - "997 998 Step Up 2: The Streets Drama,Music,Romance \n", - "998 999 Search Party Adventure,Comedy \n", - "999 1000 Nine Lives Comedy,Family,Fantasy \n", - "\n", - " Description Director \\\n", - "995 A tight-knit team of rising investigators, alo... Billy Ray \n", - "996 Three American college students studying abroa... Eli Roth \n", - "997 Romantic sparks occur between two dance studen... Jon M. Chu \n", - "998 A pair of friends embark on a mission to reuni... Scot Armstrong \n", - "999 A stuffy businessman finds himself trapped ins... Barry Sonnenfeld \n", - "\n", - " Actors Year \\\n", - "995 Chiwetel Ejiofor, Nicole Kidman, Julia Roberts... 2015 \n", - "996 Lauren German, Heather Matarazzo, Bijou Philli... 2007 \n", - "997 Robert Hoffman, Briana Evigan, Cassie Ventura,... 2008 \n", - "998 Adam Pally, T.J. Miller, Thomas Middleditch,Sh... 2014 \n", - "999 Kevin Spacey, Jennifer Garner, Robbie Amell,Ch... 2016 \n", - "\n", - " Runtime (Minutes) Rating Votes Revenue (Millions) Metascore \n", - "995 111 6.2 27585 NaN 45.0 \n", - "996 94 5.5 73152 17.54 46.0 \n", - "997 98 6.2 70699 58.01 50.0 \n", - "998 93 5.6 4881 NaN 22.0 \n", - "999 87 5.3 12435 19.64 11.0 " - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df.tail()" ] @@ -584,11 +241,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -617,27 +285,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "Index(['Rank', 'Title', 'Genre', 'Description', 'Director', 'Actors', 'Year',\n", - " 'Runtime (Minutes)', 'Rating', 'Votes', 'Revenue (Millions)',\n", - " 'Metascore'],\n", - " dtype='object')" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df.columns" ] @@ -660,24 +325,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "RangeIndex(start=0, stop=999, step=1)" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df.index" ] @@ -695,40 +360,30 @@ "metadata": { "lines_to_next_cell": 2, "solution2": "hidden", - "solution2_first": true + "solution2_first": true, + "tags": [] }, "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "0 2014\n", - "1 2012\n", - "2 2016\n", - "3 2016\n", - "4 2016\n", - " ... \n", - "994 2012\n", - "995 2015\n", - "996 2007\n", - "997 2008\n", - "998 2014\n", - "Name: Year, Length: 999, dtype: int64" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df.Year # or df['Year'] or df.loc[:, 'Year']" ] @@ -751,24 +406,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "(2006, 2016)" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df.Year.min(), df.Year.max()" ] @@ -791,36 +446,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "Rank int64\n", - "Title object\n", - "Genre object\n", - "Description object\n", - "Director object\n", - "Actors object\n", - "Year int64\n", - "Runtime (Minutes) int64\n", - "Rating float64\n", - "Votes int64\n", - "Revenue (Millions) float64\n", - "Metascore float64\n", - "dtype: object" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df.dtypes" ] @@ -838,16 +481,28 @@ "metadata": { "lines_to_next_cell": 2, "solution2": "hidden", - "solution2_first": true + "solution2_first": true, + "tags": [] }, "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -856,153 +511,9 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "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>Title</th>\n", - " <th>Genre</th>\n", - " <th>Description</th>\n", - " <th>Director</th>\n", - " <th>Actors</th>\n", - " <th>Year</th>\n", - " <th>Runtime (Minutes)</th>\n", - " <th>Rating</th>\n", - " <th>Votes</th>\n", - " <th>Revenue (Millions)</th>\n", - " <th>Metascore</th>\n", - " </tr>\n", - " </thead>\n", - " <tbody>\n", - " <tr>\n", - " <th>0</th>\n", - " <td>Guardians of the Galaxy</td>\n", - " <td>Action,Adventure,Sci-Fi</td>\n", - " <td>A group of intergalactic criminals are forced ...</td>\n", - " <td>James Gunn</td>\n", - " <td>Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...</td>\n", - " <td>2014</td>\n", - " <td>121</td>\n", - " <td>8.1</td>\n", - " <td>757074</td>\n", - " <td>333.13</td>\n", - " <td>76.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>1</th>\n", - " <td>Prometheus</td>\n", - " <td>Adventure,Mystery,Sci-Fi</td>\n", - " <td>Following clues to the origin of mankind, a te...</td>\n", - " <td>Ridley Scott</td>\n", - " <td>Noomi Rapace, Logan Marshall-Green, Michael Fa...</td>\n", - " <td>2012</td>\n", - " <td>124</td>\n", - " <td>7.0</td>\n", - " <td>485820</td>\n", - " <td>126.46</td>\n", - " <td>65.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>2</th>\n", - " <td>Split</td>\n", - " <td>Horror,Thriller</td>\n", - " <td>Three girls are kidnapped by a man with a diag...</td>\n", - " <td>M. Night Shyamalan</td>\n", - " <td>James McAvoy, Anya Taylor-Joy, Haley Lu Richar...</td>\n", - " <td>2016</td>\n", - " <td>117</td>\n", - " <td>7.3</td>\n", - " <td>157606</td>\n", - " <td>138.12</td>\n", - " <td>62.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>3</th>\n", - " <td>Sing</td>\n", - " <td>Animation,Comedy,Family</td>\n", - " <td>In a city of humanoid animals, a hustling thea...</td>\n", - " <td>Christophe Lourdelet</td>\n", - " <td>Matthew McConaughey,Reese Witherspoon, Seth Ma...</td>\n", - " <td>2016</td>\n", - " <td>108</td>\n", - " <td>7.2</td>\n", - " <td>60545</td>\n", - " <td>270.32</td>\n", - " <td>59.0</td>\n", - " </tr>\n", - " <tr>\n", - " <th>4</th>\n", - " <td>Suicide Squad</td>\n", - " <td>Action,Adventure,Fantasy</td>\n", - " <td>A secret government agency recruits some of th...</td>\n", - " <td>David Ayer</td>\n", - " <td>Will Smith, Jared Leto, Margot Robbie, Viola D...</td>\n", - " <td>2016</td>\n", - " <td>123</td>\n", - " <td>6.2</td>\n", - " <td>393727</td>\n", - " <td>325.02</td>\n", - " <td>40.0</td>\n", - " </tr>\n", - " </tbody>\n", - "</table>\n", - "</div>" - ], - "text/plain": [ - " Title Genre \\\n", - "0 Guardians of the Galaxy Action,Adventure,Sci-Fi \n", - "1 Prometheus Adventure,Mystery,Sci-Fi \n", - "2 Split Horror,Thriller \n", - "3 Sing Animation,Comedy,Family \n", - "4 Suicide Squad Action,Adventure,Fantasy \n", - "\n", - " Description Director \\\n", - "0 A group of intergalactic criminals are forced ... James Gunn \n", - "1 Following clues to the origin of mankind, a te... Ridley Scott \n", - "2 Three girls are kidnapped by a man with a diag... M. Night Shyamalan \n", - "3 In a city of humanoid animals, a hustling thea... Christophe Lourdelet \n", - "4 A secret government agency recruits some of th... David Ayer \n", - "\n", - " Actors Year Runtime (Minutes) \\\n", - "0 Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S... 2014 121 \n", - "1 Noomi Rapace, Logan Marshall-Green, Michael Fa... 2012 124 \n", - "2 James McAvoy, Anya Taylor-Joy, Haley Lu Richar... 2016 117 \n", - "3 Matthew McConaughey,Reese Witherspoon, Seth Ma... 2016 108 \n", - "4 Will Smith, Jared Leto, Margot Robbie, Viola D... 2016 123 \n", - "\n", - " Rating Votes Revenue (Millions) Metascore \n", - "0 8.1 757074 333.13 76.0 \n", - "1 7.0 485820 126.46 65.0 \n", - "2 7.3 157606 138.12 62.0 \n", - "3 7.2 60545 270.32 59.0 \n", - "4 6.2 393727 325.02 40.0 " - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df.head()" ] @@ -1026,7 +537,8 @@ "execution_count": null, "metadata": { "solution2": "hidden", - "solution2_first": true + "solution2_first": true, + "tags": [] }, "outputs": [], "source": [ @@ -1036,27 +548,29 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, + { + "cell_type": "code", + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "0 [Action, Adventure, Sci-Fi]\n", - "1 [Adventure, Mystery, Sci-Fi]\n", - "2 [Horror, Thriller]\n", - "3 [Animation, Comedy, Family]\n", - "4 [Action, Adventure, Fantasy]\n", - "Name: Genre, dtype: object" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "genres = df.Genre.str.split(',')\n", "genres.head()" @@ -1071,78 +585,9 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "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>movie_id</th>\n", - " <th>genre</th>\n", - " </tr>\n", - " </thead>\n", - " <tbody>\n", - " <tr>\n", - " <th>0</th>\n", - " <td>0</td>\n", - " <td>Action</td>\n", - " </tr>\n", - " <tr>\n", - " <th>1</th>\n", - " <td>0</td>\n", - " <td>Adventure</td>\n", - " </tr>\n", - " <tr>\n", - " <th>2</th>\n", - " <td>0</td>\n", - " <td>Sci-Fi</td>\n", - " </tr>\n", - " <tr>\n", - " <th>3</th>\n", - " <td>1</td>\n", - " <td>Adventure</td>\n", - " </tr>\n", - " <tr>\n", - " <th>4</th>\n", - " <td>1</td>\n", - " <td>Mystery</td>\n", - " </tr>\n", - " </tbody>\n", - "</table>\n", - "</div>" - ], - "text/plain": [ - " movie_id genre\n", - "0 0 Action\n", - "1 0 Adventure\n", - "2 0 Sci-Fi\n", - "3 1 Adventure\n", - "4 1 Mystery" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "genres = genres.apply(pd.Series).stack().reset_index().iloc[:, [0,2]]\n", "genres.columns = ['movie_id', 'genre']\n", @@ -1167,82 +612,24 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, - "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>movie_id</th>\n", - " <th>actor</th>\n", - " </tr>\n", - " </thead>\n", - " <tbody>\n", - " <tr>\n", - " <th>0</th>\n", - " <td>0</td>\n", - " <td>Chris Pratt</td>\n", - " </tr>\n", - " <tr>\n", - " <th>1</th>\n", - " <td>0</td>\n", - " <td>Vin Diesel</td>\n", - " </tr>\n", - " <tr>\n", - " <th>2</th>\n", - " <td>0</td>\n", - " <td>Bradley Cooper</td>\n", - " </tr>\n", - " <tr>\n", - " <th>3</th>\n", - " <td>0</td>\n", - " <td>Zoe Saldana</td>\n", - " </tr>\n", - " <tr>\n", - " <th>4</th>\n", - " <td>1</td>\n", - " <td>Noomi Rapace</td>\n", - " </tr>\n", - " </tbody>\n", - "</table>\n", - "</div>" - ], - "text/plain": [ - " movie_id actor\n", - "0 0 Chris Pratt\n", - "1 0 Vin Diesel\n", - "2 0 Bradley Cooper\n", - "3 0 Zoe Saldana\n", - "4 1 Noomi Rapace" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "actors = df.Actors.str.split(',').apply(pd.Series).stack().reset_index().iloc[:, [0,2]]\n", "actors.columns = ['movie_id', 'actor']\n", @@ -1268,11 +655,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1331,11 +729,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1348,7 +757,11 @@ "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1374,11 +787,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1403,11 +827,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1431,16 +866,28 @@ "metadata": { "lines_to_next_cell": 2, "solution2": "hidden", - "solution2_first": true + "solution2_first": true, + "tags": [] }, "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1465,11 +912,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1495,11 +953,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1524,11 +993,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1553,11 +1033,22 @@ "outputs": [], "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Click on the three dots below to disply the solution" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "solution2": "hidden" + "jupyter": { + "source_hidden": true + }, + "solution2": "hidden", + "tags": [] }, "outputs": [], "source": [ @@ -1650,9 +1141,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.13" + "version": "3.9.12" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } -- GitLab