Last active
August 21, 2024 00:08
-
-
Save firmai/818a2e56c2e0f61c650e1080ce670ec1 to your computer and use it in GitHub Desktop.
1-intermediate-coder.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyOnpt1IZMLAy/wb2frm4/76", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/firmai/818a2e56c2e0f61c650e1080ce670ec1/1-intermediate-coder.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"\n", | |
"### Intermediate Coder\n", | |
"\n", | |
"\n", | |
"```python\n", | |
"import pandas as pd\n", | |
"```\n", | |
"\n", | |
"Behold this line of code! It's a mystical incantation that opens the door to a secret society, a society that all quant-loving coders aspire to join!\n", | |
"\n", | |
"--------------\n", | |
"\n", | |
"So, what exactly is this Pandas?\n", | |
"\n", | |
"* First, imagine Pandas as a Swiss Army knife of data manipulation! It's a library, a powerful toolbox for coding, teeming with functions to make your life easier. And yes, there are many such toolboxes, each unique and magical in its own way. Check them out on [Github](https://github.com/trending/python?since=monthly) and [PyPi](https://pypi.org/search/?c=Topic+%3A%3A+Office%2FBusiness+%3A%3A+Financial+%3A%3A+Investment&o=-created&q=&page=1).\n", | |
"* You can acquire your Pandas (don't worry, it's completely legal and cruelty-free) by simply running `!pip install pandas` in your terminal. Welcome to the club!\n", | |
"\n", | |
"\n", | |
"And guess what? Libraries like Pandas are so incredibly handy, that they're already set up and ready to go on platforms like this Google Colab notebook. It's like having your toolkit already laid out for you. Let's see which version of our magic toolbox, Pandas, we have available. Don't be shy, peek in!\n" | |
], | |
"metadata": { | |
"id": "cGwUx1KpsuQ9" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import pandas as pd\n", | |
"\n", | |
"pd.__version__" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 56 | |
}, | |
"id": "5mAX6ewvwVzL", | |
"outputId": "bf7f78e2-1dac-48f9-8324-11dc4173a5b1" | |
}, | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"'2.1.4'" | |
], | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
} | |
}, | |
"metadata": {}, | |
"execution_count": 1 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"You might see the following messsage \"Warning this notebook was not authored by Google\" just click ``Run\n", | |
"\n", | |
"1. List item\n", | |
"2. List item\n", | |
"\n", | |
"Anyway`` ✅" | |
], | |
"metadata": { | |
"id": "QyakuI7aD3-0" | |
} | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"* Well, it seems we're dealing with a vintage (old) version of Pandas here! We know that because of the above code ``pd.__version__``.\n", | |
"\n", | |
"* Let's dive into the depths of ``PyPi``, the mystical vault teeming with the latest and greatest software libraries, to grab the latest version.\n", | |
"\n", | |
"* Let's search for 'pandas pypi' in the grand oracle, Google. And voila! The very first treasure on the list, ``Pandas`` PyPi, is our golden ticket. https://pypi.org/project/pandas/\n", | |
"\n", | |
"" | |
], | |
"metadata": { | |
"id": "5qO8j_nOydg9" | |
} | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"Yes, we can confirm that we have an old version, just look at the [PyPi](https://pypi.org/project/pandas/) page its **2.03** instead of **1.53**:\n", | |
"" | |
], | |
"metadata": { | |
"id": "Vy3gkerdzLfe" | |
} | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"To install the latest version of Pandas, we'll utilize the command ```!pip install command.```. The added **exclamation mark** isn't merely a mark of our excitement—it's a specific command that engages with the shell, or terminal.\n", | |
"\n", | |
"> A shell is a user interface for access to an operating system’s services. Most often the user interacts with the shell using a command-line interface (CLI). The terminal is a program that opens a graphical window and lets you interact with the shell.\n", | |
"\n", | |
"\n", | |
"\n", | |
"And remember, we're after the most current version. So, our next step is to navigate to the **Release History** section on the Pandas PyPi page.\n", | |
"\n", | |
"\n", | |
"" | |
], | |
"metadata": { | |
"id": "sdbketEszZV2" | |
} | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"" | |
], | |
"metadata": { | |
"id": "nOECF0p00za6" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!pip install pandas==2.2.2 ## okay nothing to be scared of, let's run this for the latest version" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "HUyccZNmzYzM", | |
"outputId": "459f4773-563b-40b4-831e-93c7a9197ddb" | |
}, | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Collecting pandas==2.2.2\n", | |
" Downloading pandas-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (19 kB)\n", | |
"Requirement already satisfied: numpy>=1.22.4 in /usr/local/lib/python3.10/dist-packages (from pandas==2.2.2) (1.26.4)\n", | |
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas==2.2.2) (2.8.2)\n", | |
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas==2.2.2) (2024.1)\n", | |
"Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.10/dist-packages (from pandas==2.2.2) (2024.1)\n", | |
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.2->pandas==2.2.2) (1.16.0)\n", | |
"Downloading pandas-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.0 MB)\n", | |
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.0/13.0 MB\u001b[0m \u001b[31m60.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | |
"\u001b[?25hInstalling collected packages: pandas\n", | |
" Attempting uninstall: pandas\n", | |
" Found existing installation: pandas 2.1.4\n", | |
" Uninstalling pandas-2.1.4:\n", | |
" Successfully uninstalled pandas-2.1.4\n", | |
"\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", | |
"cudf-cu12 24.4.1 requires pandas<2.2.2dev0,>=2.0, but you have pandas 2.2.2 which is incompatible.\n", | |
"google-colab 1.0.0 requires pandas==2.1.4, but you have pandas 2.2.2 which is incompatible.\u001b[0m\u001b[31m\n", | |
"\u001b[0mSuccessfully installed pandas-2.2.2\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"***Sometimes!!*** we get a scary red message that tells us to restart the runtime, what does that mean?? Well it means we have to click <strong><font size=3 color=\"orange\">Runtime</font></strong> <strong><font size=3 color=\"orange\">-> Restart runtime</font></strong>\n", | |
"\n", | |
"" | |
], | |
"metadata": { | |
"id": "-TSAwIh-2VSJ" | |
} | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"Okay but why restart the library? Well the problem is the old library is already loaded in memory, and we have to purge it! We want the new library to be loaded in memory, and the easiest wat is to restart the runtime (kernel). This simply means that our Python environment needs a refresh.\n", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment