From 23f702d74963d2cab589b6eaa463ba7c97ef56c1 Mon Sep 17 00:00:00 2001 From: DrSaadLa Date: Sat, 6 Jan 2024 07:12:38 +0300 Subject: [PATCH] Add Basic data structures chapter and create two notebooks for series and data frames --- .../02_BasicDataStructures/1_Series.ipynb | 92 +++++++++++++ .../02_BasicDataStructures/2_DataFrames.ipynb | 121 ++++++++++++++++++ .../01. Reading Plain Text Data.ipynb | 74 ++++++++++- scripts/importlibs.py | 12 +- 4 files changed, 290 insertions(+), 9 deletions(-) create mode 100644 Tutorials/02_BasicDataStructures/1_Series.ipynb create mode 100644 Tutorials/02_BasicDataStructures/2_DataFrames.ipynb rename Tutorials/{02_ReadingData => 03_ReadingData}/01. Reading Plain Text Data.ipynb (89%) diff --git a/Tutorials/02_BasicDataStructures/1_Series.ipynb b/Tutorials/02_BasicDataStructures/1_Series.ipynb new file mode 100644 index 0000000..1a00809 --- /dev/null +++ b/Tutorials/02_BasicDataStructures/1_Series.ipynb @@ -0,0 +1,92 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "4a699447-f6c2-4385-a32e-4db8f5202d01", + "metadata": {}, + "source": [ + "
\n", + " Basic Data Structures with Polars
\n", + " Series\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "c34b1ebb-1849-4b6c-bbd4-a66919a78008", + "metadata": {}, + "outputs": [], + "source": [ + "# ============================================================\n", + "# =\n", + "# Title: Basic Data Structures with Polars =\n", + "# Series =\n", + "# --------------------------------- =\n", + "# =\n", + "# Author: Dr. Saad Laouadi =\n", + "# =\n", + "# Copyright: Dr. Saad Laouadi =\n", + "# ============================================================\n", + "# =\n", + "# LICENSE =\n", + "# ---------------------- =\n", + "# =\n", + "# This material is intended for educational =\n", + "# purposes only and may not be used directly in =\n", + "# courses, video recordings, or similar =\n", + "# without prior consent from the author. =\n", + "# When using or referencing this material, =\n", + "# proper credit must be attributed to the =\n", + "# author. =\n", + "# ============================================================" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "7a9be308-bfec-44e1-b2f6-14187eba305e", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Environment Setup\n", + "import sys\n", + "sys.path.append('../../scripts/') \n", + "\n", + "# import the working libraries\n", + "from importlibs import *" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "889cdc44-6fd2-4ea6-97a9-e63040f3aca6", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "PolarsEnv", + "language": "python", + "name": "plenv" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.1" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Tutorials/02_BasicDataStructures/2_DataFrames.ipynb b/Tutorials/02_BasicDataStructures/2_DataFrames.ipynb new file mode 100644 index 0000000..114bd9d --- /dev/null +++ b/Tutorials/02_BasicDataStructures/2_DataFrames.ipynb @@ -0,0 +1,121 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "4a699447-f6c2-4385-a32e-4db8f5202d01", + "metadata": {}, + "source": [ + "
\n", + " Basic Data Structures with Polars
\n", + " DataFrames\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "c34b1ebb-1849-4b6c-bbd4-a66919a78008", + "metadata": {}, + "outputs": [], + "source": [ + "# ============================================================\n", + "# =\n", + "# Title: Basic Data Structures with Polars =\n", + "# Data Frames =\n", + "# --------------------------------- =\n", + "# =\n", + "# Author: Dr. Saad Laouadi =\n", + "# =\n", + "# Copyright: Dr. Saad Laouadi =\n", + "# ============================================================\n", + "# =\n", + "# LICENSE =\n", + "# ---------------------- =\n", + "# =\n", + "# This material is intended for educational =\n", + "# purposes only and may not be used directly in =\n", + "# courses, video recordings, or similar =\n", + "# without prior consent from the author. =\n", + "# When using or referencing this material, =\n", + "# proper credit must be attributed to the =\n", + "# author. =\n", + "# ============================================================" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "7a9be308-bfec-44e1-b2f6-14187eba305e", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "******************************************\n", + " The imported libs are: \n", + "******************************************\n", + "polars version is : 0.20.2\n", + "pandas version is : 2.1.4\n", + "numpy version is : 1.26.2\n", + "pyarrow version is: 14.0.2\n", + "******************************************\n", + "The imported builtin modules are:\n", + "['os', 'sys', 'pathlib', 'time', 'shutil', 're']\n", + "**************************************************************\n", + "The python executable path is:\n", + " /usr/local/Caskroom/mambaforge/base/envs/plenv/bin/python3.12\n", + "**************************************************************\n", + "\n", + "....................\n", + "Important Reminder:\n", + "....................\n", + "\n", + "Before proceeding, please ensure that you have activated the appropriate virtual environment for this project.\n", + "This step is crucial to maintain consistent dependencies and project settings.\n", + "...............................................................................\n" + ] + } + ], + "source": [ + "# Environment Setup\n", + "import sys\n", + "sys.path.append('../../scripts/') \n", + "\n", + "# import the working libraries\n", + "from importlibs import *" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "889cdc44-6fd2-4ea6-97a9-e63040f3aca6", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "PolarsEnv", + "language": "python", + "name": "plenv" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.1" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Tutorials/02_ReadingData/01. Reading Plain Text Data.ipynb b/Tutorials/03_ReadingData/01. Reading Plain Text Data.ipynb similarity index 89% rename from Tutorials/02_ReadingData/01. Reading Plain Text Data.ipynb rename to Tutorials/03_ReadingData/01. Reading Plain Text Data.ipynb index 1286a63..fc997aa 100644 --- a/Tutorials/02_ReadingData/01. Reading Plain Text Data.ipynb +++ b/Tutorials/03_ReadingData/01. Reading Plain Text Data.ipynb @@ -5,7 +5,9 @@ "id": "81bdbb95-7e4c-4765-a561-f5986649bc1a", "metadata": {}, "source": [ - "# Reading Comma Separated Value Data " + "
\n", + " Reading Comma Separated Value Data (CSV)\n", + "
" ] }, { @@ -17,8 +19,68 @@ }, "outputs": [], "source": [ - "# Environment setup\n", - "import polars as pl" + "# ============================================================\n", + "# =\n", + "# Title: Reading CSV Data with Polars =\n", + "# --------------------------------- =\n", + "# =\n", + "# Author: Dr. Saad Laouadi =\n", + "# =\n", + "# Copyright: Dr. Saad Laouadi =\n", + "# ============================================================\n", + "# =\n", + "# LICENSE =\n", + "# ---------------------- =\n", + "# =\n", + "# This material is intended for educational =\n", + "# purposes only and may not be used directly in =\n", + "# courses, video recordings, or similar =\n", + "# without prior consent from the author. =\n", + "# When using or referencing this material, =\n", + "# proper credit must be attributed to the =\n", + "# author. =\n", + "# ============================================================" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "030a2ad2-df5b-4812-bca5-c9f7cdf96540", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "******************************************\n", + " The imported libs are: \n", + "******************************************\n", + "polars version is : 0.20.2\n", + "pandas version is : 2.1.4\n", + "numpy version is : 1.26.2\n", + "pyarrow version is: 14.0.2\n", + "******************************************\n", + "The imported builtin modules are:\n", + "['os', 'sys', 'pathlib', 'time', 'shutil', 're']\n", + "**************************************************************\n", + "The python executable path is:\n", + " /usr/local/Caskroom/mambaforge/base/envs/plenv/bin/python3.12\n", + "**************************************************************\n", + "Important Reminder:\n", + "Before proceeding, please ensure that you have activated the appropriate virtual environment for this project.\n", + "This step is crucial to maintain consistent dependencies and project settings.\n" + ] + } + ], + "source": [ + "# Environment Setup\n", + "import sys\n", + "sys.path.append('../../scripts/') \n", + "\n", + "# import the working libraries\n", + "from importlibs import *" ] }, { @@ -518,9 +580,9 @@ } ], "source": [ - "for meth in dir(pl):\n", - " if not meth.startswith('_'):\n", - " print(meth)" + "# for meth in dir(pl):\n", + "# if not meth.startswith('_'):\n", + "# print(meth)" ] }, { diff --git a/scripts/importlibs.py b/scripts/importlibs.py index c456d1b..985d9ca 100644 --- a/scripts/importlibs.py +++ b/scripts/importlibs.py @@ -52,7 +52,13 @@ def typewriter_message(message, delay=0.01): time.sleep(delay) print() - -message = "Important Reminder:\nBefore proceeding, please ensure that you have activated the appropriate virtual environment for this project.\nThis step is crucial to maintain consistent dependencies and project settings." +print() + +typewriter_message("."*20) +typewriter_message("Important Reminder:") +typewriter_message("."*20) + +message = "\nBefore proceeding, please ensure that you have activated the appropriate virtual environment for this project.\nThis step is crucial to maintain consistent dependencies and project settings." -typewriter_message(message) \ No newline at end of file +typewriter_message(message) +typewriter_message("."*79) \ No newline at end of file