From a09c663d75a3d9d6352a1bfe98622674d0836780 Mon Sep 17 00:00:00 2001 From: AfiMaameDufie Date: Tue, 27 Jan 2026 18:15:59 +0000 Subject: [PATCH 1/5] Add recommended python version --- python/00_open_mongodb.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/00_open_mongodb.ipynb b/python/00_open_mongodb.ipynb index 10f1e5e..1141030 100644 --- a/python/00_open_mongodb.ipynb +++ b/python/00_open_mongodb.ipynb @@ -6,7 +6,7 @@ "source": [ "# Open MongoDB Using the MongoDB Extension\n", "\n", - "1. click on the MongoDB extension on the side panel\n", + "1. Click on the MongoDB extension on the side panel\n", "2. To connect to the local database, click on ‘Library DB’ in the list of connections on the left side" ] }, From ea44e01d9e34e90c196dfa1ec6a241eed70e7351 Mon Sep 17 00:00:00 2001 From: AfiMaameDufie Date: Tue, 27 Jan 2026 18:18:52 +0000 Subject: [PATCH 2/5] fixed overkill solution and dupicates --- python/10_find.ipynb | 41 +++-------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/python/10_find.ipynb b/python/10_find.ipynb index 1c62dc7..698f5c0 100644 --- a/python/10_find.ipynb +++ b/python/10_find.ipynb @@ -84,7 +84,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Exercise: find all the books that have less than 50 pages and print only the title and pages" + "## Find all the books that have less than 50 pages and print only the title and pages" ] }, { @@ -93,11 +93,7 @@ "metadata": {}, "outputs": [], "source": [ - "filter = { \n", - " \"$and\": [\n", - " { \"pages\": { \"$lt\": 50 }}\n", - " ]\n", - "}\n", + "filter = { \"pages\": { \"$lt\": 50 } }\n", "\n", "projection = { \"title\": 1, \"pages\": 1 }\n", "\n", @@ -107,33 +103,6 @@ " print(book) " ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Find all the books that have less than 50 pages and project only the title and pages" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "filter = { \n", - " \"$and\": [\n", - " { \"pages\": { \"$lt\": 50 }}\n", - " ]\n", - "}\n", - "\n", - "projection = { \"title\": 1, \"pages\": 1 }\n", - "\n", - "cursor = books.find(filter, projection).limit(10)\n", - "\n", - "for book in cursor:\n", - " print(book)" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -147,11 +116,7 @@ "metadata": {}, "outputs": [], "source": [ - "filter = { \n", - " \"$and\": [\n", - " { \"pages\": { \"$lt\": 50 }},\n", - " ]\n", - "}\n", + "filter = { \"pages\": { \"$lt\": 50 } }\n", "\n", "projection = {\n", " \"_id\": 0,\n", From a501dea0eecc8d309ec6b7aee882a6f4c48326af Mon Sep 17 00:00:00 2001 From: AfiMaameDufie Date: Tue, 27 Jan 2026 18:20:21 +0000 Subject: [PATCH 3/5] Add/python version --- python/01_connect_database.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/01_connect_database.ipynb b/python/01_connect_database.ipynb index 166ef17..178ce41 100644 --- a/python/01_connect_database.ipynb +++ b/python/01_connect_database.ipynb @@ -15,7 +15,7 @@ "source": [ "## Select the Python Kernel\n", "\n", - "To run the code cells in these notebooks you need to select the appropriate kernel (programming language). In this case is Python. Click on the `Select Kernel` button at the top right, then `Python Environments` > `Choose the recommended Python environment`" + "To run the code cells in these notebooks you need to select the appropriate kernel (programming language). In this case is Python. Click on the `Select Kernel` button at the top right, then `Python Environments` > `Choose the recommended Python environment`. For this workshop, we will use Python 3.11." ] }, { From 0b95b5a3530709ef46f441e42fd06c525dd790ff Mon Sep 17 00:00:00 2001 From: AfiMaameDufie Date: Tue, 27 Jan 2026 18:20:59 +0000 Subject: [PATCH 4/5] Increase limit of query output --- python/11_find_arrays.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/11_find_arrays.ipynb b/python/11_find_arrays.ipynb index 809ca4d..9fdedf7 100644 --- a/python/11_find_arrays.ipynb +++ b/python/11_find_arrays.ipynb @@ -115,7 +115,7 @@ " {\"genres\": {\"$in\": \n", " [\"Family Life\", \"Fiction\"]\n", " }\n", - " }).limit(10)\n", + " }).limit(15)\n", "\n", "for book in cursor:\n", " print(f'{book[\"title\"]} - genre: {book[\"genres\"]}')\n", From 63463b86d7b1ed0ea741b00efef6cc216b5634f2 Mon Sep 17 00:00:00 2001 From: AfiMaameDufie Date: Tue, 27 Jan 2026 18:22:10 +0000 Subject: [PATCH 5/5] Remove/combine limit and sort cell --- python/20_project_sort_limit.ipynb | 37 ++++-------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/python/20_project_sort_limit.ipynb b/python/20_project_sort_limit.ipynb index 866097a..a8e5ab3 100644 --- a/python/20_project_sort_limit.ipynb +++ b/python/20_project_sort_limit.ipynb @@ -52,7 +52,7 @@ "id": "4", "metadata": {}, "source": [ - "## Sort books by descending number of pages" + "## Use limit() and sort() books by descending number of pages" ] }, { @@ -73,35 +73,6 @@ " print(book)" ] }, - { - "cell_type": "markdown", - "id": "6", - "metadata": {}, - "source": [ - "## Limit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "7", - "metadata": {}, - "outputs": [], - "source": [ - "projection = {\n", - " \"title\": 1,\n", - " \"pages\": 1\n", - "}\n", - "\n", - "cursor = books.find(\n", - " {}, # empty filter, all books\n", - " projection\n", - ").sort(\"pages\", -1).limit(10)\n", - "\n", - "for book in cursor:\n", - " print(f\"{book['title']} - {book['pages']}\")" - ] - }, { "cell_type": "markdown", "id": "8", @@ -119,13 +90,13 @@ "source": [ "projection = {\n", " \"title\": 1,\n", - " \"pages\": 1\n", + " \"year\": 1\n", "}\n", "\n", - "cursor = books.find({}, projection).sort(\"pages\", -1).skip(4).limit(10)\n", + "cursor = books.find({}, projection).sort(\"year\", -1).skip(4).limit(10)\n", "\n", "for book in cursor:\n", - " print(f\"{book['title']}\")" + " print(f\"{book['title']} - {book['year']}\")" ] }, {