diff --git a/Labs/Python_Notebooks/LAB1/.ipynb_checkpoints/Python_tutorial-checkpoint.ipynb b/Labs/Python_Notebooks/LAB1/.ipynb_checkpoints/Python_tutorial-checkpoint.ipynb new file mode 100644 index 000000000..ac44f397a --- /dev/null +++ b/Labs/Python_Notebooks/LAB1/.ipynb_checkpoints/Python_tutorial-checkpoint.ipynb @@ -0,0 +1,5029 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Python Basic Tutorial " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "print(\"Hola mundo\")\n", + "\n", + "B : new lines\n", + "\n", + "DD : drop lines \n", + "\n", + "shift: select many lines\n", + "\n", + "run : ctr + enter " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Libraries\n", + "\n", + "A library is a collection of modules or a single module. Modules are python programs that can be imported in another Python program. Libraries are the tools we will use to make our program.\n", + "\n", + "Some special libraries such import $TensorFlow, Keras, Geopandas$ requiere of using Conda Promtp. We back this issue later. \n", + "\n", + "\n", + "\\begin{equation}\n", + " u_i\n", + "\\end{equation}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!pip install pandas numpy\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'pandas'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_8280\\1866944009.py\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m# libraies t use date base and arrays\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mpandas\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mpd\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'pandas'" + ] + } + ], + "source": [ + "# libraies t use date base and arrays\n", + "import pandas as pd\n", + "import numpy as np" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "np.DataFrame\n", + "sb.hexibn (c, y)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Python Types\n", + "\n", + "There are three key python types: int, float, string and boolean." + ] + }, + { + "cell_type": "code", + "execution_count": 269, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 269, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Int type\n", + "edad = 25\n", + "edad\n", + "\n", + "type(edad)" + ] + }, + { + "cell_type": "code", + "execution_count": 270, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 270, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Float type\n", + "precio = 19.99\n", + "type(precio)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "complex" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "numero_complejo = 3 + 4j # Parte real + parte imaginaria\n", + "numero_complejo\n", + "type(numero_complejo)" + ] + }, + { + "cell_type": "code", + "execution_count": 271, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "str" + ] + }, + "execution_count": 271, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#String type\n", + "mensaje = \"Hola, mundo!\"\n", + "\n", + "type(mensaje)" + ] + }, + { + "cell_type": "code", + "execution_count": 272, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'H'" + ] + }, + "execution_count": 272, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "mensaje[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 274, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "H ; Hola, \n" + ] + } + ], + "source": [ + "print(mensaje[0], \";\", mensaje[0:6])" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " \n", + " \n" + ] + } + ], + "source": [ + "# Boolean variables\n", + "a = True \n", + "b = False \n", + "\n", + "print(type(a), '\\n', type(b))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 275, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 275, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"a\" == \"a\"" + ] + }, + { + "cell_type": "code", + "execution_count": 160, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n" + ] + } + ], + "source": [ + "print(\"a\" != \"b\") # True, because \"a\" and \"b\" are different\n", + "print(\"a\" != \"a\") # False, because \"a\" and \"a\" are the same\n" + ] + }, + { + "cell_type": "code", + "execution_count": 276, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True \n", + " True\n" + ] + } + ], + "source": [ + "z1 = (10 < 20)\n", + "\n", + "z2 = (1==1)\n", + "\n", + "#z1\n", + "\n", + "print(z2,'\\n', z1)\n", + "#int(z1)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.0 Tuple\n", + "\n", + "#### It is an ordered and immutable Python object" + ] + }, + { + "cell_type": "code", + "execution_count": 284, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(10, 20, 30)" + ] + }, + "execution_count": 284, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "coordenadas = (10, 20, 30)\n", + "#coordenadas[0] = 50 # Error: 'tuple' object does not support item assignment\n", + "coordenadas" + ] + }, + { + "cell_type": "code", + "execution_count": 282, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Suma: 83 \n", + " Minimo: 1 \n", + " Maximo: 20\n" + ] + } + ], + "source": [ + "T1 = (1,4,8,10,20,15,4,5,8,8)\n", + "\n", + "print(type(T1))\n", + "\n", + "\n", + "print(\"Suma:\", sum(T1),'\\n', \"Minimo:\", min(T1), '\\n', \"Maximo:\", max(T1))" + ] + }, + { + "cell_type": "code", + "execution_count": 167, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sum: 83 \n", + " Minimum: 1 \n", + " Maximum: 20 \n", + " Average: 8.3\n" + ] + } + ], + "source": [ + "print(\"Sum:\", sum(T1), '\\n', \n", + " \"Minimum:\", min(T1), '\\n', \n", + " \"Maximum:\", max(T1), '\\n', \n", + " \"Average:\", sum(T1) / len(T1))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 168, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "20" + ] + }, + "execution_count": 168, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "T1[4]" + ] + }, + { + "cell_type": "code", + "execution_count": 170, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(4, 8, 10, 20, 15, 4, 5, 8)" + ] + }, + "execution_count": 170, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "T1[1:9] # let us for selecting from 0 to before 4 [0-3]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4.0 List\n", + "\n", + "#### It is an ordered and mutable Python container." + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "list" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Empty List\n", + "\n", + "L1 = []\n", + "\n", + "type(L1)" + ] + }, + { + "cell_type": "code", + "execution_count": 286, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[3, 4, 5, 'ATE', 'BARRANCO', 'BREÑA', 'CALLAO', 'CARABAYLLO']\n" + ] + }, + { + "data": { + "text/plain": [ + "[3, 4]" + ] + }, + "execution_count": 286, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a = [3,4,5,\"ATE\", 'BARRANCO','BREÑA', 'CALLAO', 'CARABAYLLO']\n", + "type(a)\n", + "print(a)\n", + "\n", + "a[0:2]" + ] + }, + { + "cell_type": "code", + "execution_count": 287, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[3, 4, 5, 'ATE', 'BARRANCO', 'BREÑA', 'CALLAO', 'CARABAYLLO', ['COMAS']]\n" + ] + } + ], + "source": [ + "#a.append([\"San Miguel\", \"La marina\"])\n", + "a.append([\"COMAS\"])\n", + "\n", + "print(a)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Indexing\n", + "Selecting elements starting from 0. I know it sounds crazy. \n", + "Selecting takes one position before the last requested column" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "first element: 3\n", + "[4, 5, 'ATE']\n", + "first 5 element: [3, 4, 5, 'ATE', 'BARRANCO']\n" + ] + } + ], + "source": [ + "print('first element:',a[0])\n", + "print(a[1:4]) # takes element position 1° to 3°, NOT 4°\n", + "print('first 5 element:',a[0:5]) # 0,1,2,3,4 " + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [], + "source": [ + "# use next line to complete list\n", + "b = ['ATE', 'BARRANCO','BREÑA', 'CALLAO', 'CARABAYLLO','CHACLACAYO','CHORRILLOS','CIENEGUILLA'\n", + " ,'COMAS','EL_AGUSTINO','INDEPENDENCIA']" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "INDEPENDENCIA\n" + ] + } + ], + "source": [ + "# last elements \n", + "print(b[-1])" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['COMAS', 'EL_AGUSTINO', 'INDEPENDENCIA']\n" + ] + } + ], + "source": [ + "print(b[-3:]) #end" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "11" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(b) # Amount" + ] + }, + { + "cell_type": "code", + "execution_count": 288, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['ATE', 'BARRANCO', 'BREÑA', 'CALLAO', 'CARABAYLLO', 'CHACLACAYO', 'CHORRILLOS', 'CIENEGUILLA', 'COMAS', 'EL_AGUSTINO', 'INDEPENDENCIA', 10, 20, 30, 10, 20, 30]\n" + ] + }, + { + "data": { + "text/plain": [ + "17" + ] + }, + "execution_count": 288, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# add elements to list\n", + "num = [10,20,30]\n", + "b.extend(num)\n", + "print(b)\n", + "len(b)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Dictionaries - THE WITCH\n", + "It is a unordered and mutable Python container." + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "dict_keys(['Berlin', 'Hamburg', 'Munich', 'Cologne', 'Frankfurt'])" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# dictionary containing the population of the 5 largest german cities\n", + "population = {'Berlin': 3748148, 'Hamburg': 1822445, 'Munich': 1471508, 'Cologne': 1085664, 'Frankfurt': 753056 }\n", + "population.keys()\n", + "\n", + "\n", + "# enaho.rename( column, {var : ingreso_hora})" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1822445" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "population['Hamburg']" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [], + "source": [ + "population_18_19 = {'Berlin': [3748148, 38000, \"alex\"], 'Hamburg': [1822445, 1922445], \n", + " 'Munich': 1471508, 'Cologne': 1085664, 'Frankfurt': 753056 , 'lima': 1100000}" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[3748148, 38000, 'alex']" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "population_18_19['Berlin']" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "7795157" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pop_germnay = population_18_19[\"Berlin\"][0] + population_18_19[\"Munich\"] + population_18_19[\"Hamburg\"][0]+ population_18_19[\"Frankfurt\"]\n", + "pop_germnay" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Array (vectors and matrix)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### [Key Methods](https://cs231n.github.io/python-numpy-tutorial/)\n", + "\n", + "| Method | Description |\n", + "| -------- | ------------ |\n", + "|dtype | type of elements in the array|\n", + "|ndim | dimension of array|\n", + "|shape | tuple with the dimmension of the array|\n", + "|size | total number of elements in the array|" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "numpy.ndarray" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a = np.array( [1, 2, 3, 4, 5] )\n", + "a\n", + "type(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([3, 4, 5, 6, 6])" + ] + }, + "execution_count": 71, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "c1 = np.array([3,4,5,6,6])\n", + "c1" + ] + }, + { + "cell_type": "code", + "execution_count": 295, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 295, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a = np.array([1,2,3,4,5])\n", + "#a = [1,2,3,4,5]\n", + "#a.size \n", + "len(a) " + ] + }, + { + "cell_type": "code", + "execution_count": 296, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5\n", + "(5,)\n", + "1\n" + ] + }, + { + "data": { + "text/plain": [ + "5" + ] + }, + "execution_count": 296, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "print(a.size)\n", + "print(a.shape)\n", + "print(a.ndim)\n", + "\n", + "len(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[3 4 2]\n", + " [1 2 6]]\n", + "n° elements: 6 \n", + " rows and columns: (2, 3) \n", + " n° dimension: 2\n" + ] + } + ], + "source": [ + "# 2D array\n", + "M = np.array( [ [3, 4, 2], [1, 2, 6] ] )\n", + "print(M)\n", + "\n", + "M1 = np.nan\n", + "M1\n", + "print(\"n° elements:\", M.size, '\\n', \"rows and columns:\", M.shape, '\\n', \"n° dimension:\", M.ndim)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### ***[Array Creation Routines](https://numpy.org/doc/stable/reference/routines.array-creation.html)***\n", + "\n", + "\n", + "|Function|Return|\n", + "| --- | --- |\n", + "|arange( )|array of sequence|\n", + "|eye( )|diagonal array|\n", + "|ones( )|array of ones|\n", + "|zeros( )|array of zeros|" + ] + }, + { + "cell_type": "code", + "execution_count": 297, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[ 1 6 11]\n" + ] + }, + { + "data": { + "text/plain": [ + "numpy.ndarray" + ] + }, + "execution_count": 297, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "peru = np.arange(start = 1,stop = 13,step = 5)\n", + "print(peru)\n", + "type(peru)" + ] + }, + { + "cell_type": "code", + "execution_count": 298, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])" + ] + }, + "execution_count": 298, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y = np.arange(1,11)\n", + "y" + ] + }, + { + "cell_type": "code", + "execution_count": 299, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[ 0 5 10 15]\n", + "[ 0 5 10]\n" + ] + } + ], + "source": [ + "y = np.arange( 0, 20, 5 )\n", + "print(y)\n", + "print(y[0:3])" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1, 2, 3, 4, 5, 6, 7, 8, 9])" + ] + }, + "execution_count": 82, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y1 = np.arange( 1, 10 ) # one step \n", + "y1" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] \n", + "\n", + "[[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]]\n" + ] + } + ], + "source": [ + "a4 = np.ones(10)\n", + "print(a4, '\\n')\n", + "a5 = np.ones((10,10))\n", + "print(a5)" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0. 0. 0. 0. 0.] \n", + "\n", + "[[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]\n" + ] + } + ], + "source": [ + "a6 = np.zeros(5)\n", + "print(a6,'\\n')\n", + "a7 = np.zeros((10,10))\n", + "print(a7)" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],\n", + " [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n", + " [ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39],\n", + " [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11],\n", + " [ 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]])" + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a8 = np.array([np.arange(0,10), np.arange(10,20), np.arange(30,40), np.arange(-20,-10), np.arange(2,21,2)])\n", + "a8" + ] + }, + { + "cell_type": "code", + "execution_count": 301, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39],\n", + " [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11],\n", + " [ 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]])" + ] + }, + "execution_count": 301, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a8[2:5,:] # rows selection\n", + "#a8[2:5] # rows selection" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0, 1, 2, 3, 4, 5],\n", + " [ 10, 11, 12, 13, 14, 15],\n", + " [ 30, 31, 32, 33, 34, 35],\n", + " [-20, -19, -18, -17, -16, -15],\n", + " [ 2, 4, 6, 8, 10, 12]])" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a8[:,0:6] # columns selecrtion" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### ***[Array Manipulation](https://numpy.org/doc/stable/reference/routines.array-manipulation.html)***" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23]\n" + ] + } + ], + "source": [ + "# Reshape\n", + "\n", + "w = np.arange(0,24)\n", + "print( w )" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 0 1 2 3 4 5]\n", + " [ 6 7 8 9 10 11]\n", + " [12 13 14 15 16 17]\n", + " [18 19 20 21 22 23]]\n" + ] + } + ], + "source": [ + "print(w.reshape(4,6))" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 0]\n", + " [ 1]\n", + " [ 2]\n", + " [ 3]\n", + " [ 4]\n", + " [ 5]\n", + " [ 6]\n", + " [ 7]\n", + " [ 8]\n", + " [ 9]\n", + " [10]\n", + " [11]\n", + " [12]\n", + " [13]\n", + " [14]\n", + " [15]\n", + " [16]\n", + " [17]\n", + " [18]\n", + " [19]\n", + " [20]\n", + " [21]\n", + " [22]\n", + " [23]]\n" + ] + } + ], + "source": [ + "print(w.reshape(24,1))" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[ 0 1 2 3 4 5 6 7 8 9 10 11]\n", + " [12 13 14 15 16 17 18 19 20 21 22 23]]\n" + ] + } + ], + "source": [ + "print(w.reshape(2,12))" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]\n", + " [0. 0.]] \n", + " \n", + " [[1. 1. 1. 1.]\n", + " [1. 1. 1. 1.]\n", + " [1. 1. 1. 1.]\n", + " [1. 1. 1. 1.]\n", + " [1. 1. 1. 1.]\n", + " [1. 1. 1. 1.]\n", + " [1. 1. 1. 1.]\n", + " [1. 1. 1. 1.]]\n" + ] + } + ], + "source": [ + "M1 = np.zeros( (8, 2) )\n", + "M2 = np.ones( (8, 4) )\n", + "print(M1,\"\\n\",\"\\n\", M2)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.]])" + ] + }, + "execution_count": 95, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "M3 = np.hstack((M1,M2)) # add columns in horizontal way\n", + "M3" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Axis\n", + "\n", + "### axis = 0 : vertical operation\n", + "### axis = 1 : horizontal operation" + ] + }, + { + "cell_type": "code", + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.]])" + ] + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "con1 = np.concatenate((M1,M2), axis = 1) # add more columns. This is a horizontal operation\n", + "con1" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "mat5 \n", + " [[0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1.]]\n" + ] + } + ], + "source": [ + "# Transpose\n", + "mat_3 = M3.T\n", + "print(\"mat5 \\n\" , mat_3)" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[2 2 3 4 5 1]\n", + " [1 5 5 9 8 2]]\n" + ] + } + ], + "source": [ + "M4 = np.array([[2,2,3,4,5,1],[1,5,5,9,8,2]])\n", + "M4.shape\n", + "print(M4)" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [2., 2., 3., 4., 5., 1.],\n", + " [1., 5., 5., 9., 8., 2.]])" + ] + }, + "execution_count": 107, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "M5 = np.vstack((M3,M4)) # add columns in horizontal way\n", + "M5" + ] + }, + { + "cell_type": "code", + "execution_count": 108, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [0., 0., 1., 1., 1., 1.],\n", + " [2., 2., 3., 4., 5., 1.],\n", + " [1., 5., 5., 9., 8., 2.]])" + ] + }, + "execution_count": 108, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "con2 = np.concatenate((M3,M4), axis = 0) # add more rows. This is a vertical operation\n", + "con2" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "mat4 \n", + " [[0. 0. 0. 0. 0. 0. 0. 0. 2. 1.]\n", + " [0. 0. 0. 0. 0. 0. 0. 0. 2. 5.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 3. 5.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 4. 9.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 5. 8.]\n", + " [1. 1. 1. 1. 1. 1. 1. 1. 1. 2.]]\n" + ] + } + ], + "source": [ + "\n", + "mat_5 = M5.T\n", + "print(\"mat4 \\n\" , mat_5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# [Pandas](https://pandas.pydata.org/docs/user_guide/index.html)\n", + "It helps us to store data in a 2-dimensional labeled data structure with columns of potentially different types." + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": 171, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Students': ['Alejandro', 'Pedro', 'Ramiro', 'Axel', 'Juan'],\n", + " 'Math': [15, 16, 10, 12, 13],\n", + " 'English': [13, 9, 16, 14, 17],\n", + " 'Art': [12, 16, 15, 19, 10]}" + ] + }, + "execution_count": 171, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# crear lists\n", + "students = [\"Alejandro\",\"Pedro\",\"Ramiro\",\"Axel\",\"Juan\"]\n", + "math = [15,16,10,12,13]\n", + "english = [13,9,16,14,17]\n", + "art = [12,16,15,19,10]\n", + "\n", + "# Make a dictionary\n", + "grades = {\"Students\": students, \"Math\":math, \"English\":english, \"Art\":art}\n", + "grades" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
StudentsMathEnglishArt
0Alejandro151312
1Pedro16916
2Ramiro101615
3Axel121419
4Juan131710
\n", + "
" + ], + "text/plain": [ + " Students Math English Art\n", + "0 Alejandro 15 13 12\n", + "1 Pedro 16 9 16\n", + "2 Ramiro 10 16 15\n", + "3 Axel 12 14 19\n", + "4 Juan 13 17 10" + ] + }, + "execution_count": 115, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data1 = pd.DataFrame(grades)\n", + "data1" + ] + }, + { + "cell_type": "code", + "execution_count": 116, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
StMaEnAr
0Alejandro151312
1Pedro16916
2Ramiro101615
3Axel121419
4Juan131710
\n", + "
" + ], + "text/plain": [ + " St Ma En Ar\n", + "0 Alejandro 15 13 12\n", + "1 Pedro 16 9 16\n", + "2 Ramiro 10 16 15\n", + "3 Axel 12 14 19\n", + "4 Juan 13 17 10" + ] + }, + "execution_count": 116, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Change columns names\n", + "dic1 = { \"Students\":'St', \"Math\":'Ma', \"English\":'En', \"Art\":'Ar'} # dictionary\n", + "data1.rename( columns = dic1)" + ] + }, + { + "cell_type": "code", + "execution_count": 172, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
StMaEnAr
0Alejandro151312
1Pedro16916
2Ramiro101615
3Axel121419
4Juan131710
\n", + "
" + ], + "text/plain": [ + " St Ma En Ar\n", + "0 Alejandro 15 13 12\n", + "1 Pedro 16 9 16\n", + "2 Ramiro 10 16 15\n", + "3 Axel 12 14 19\n", + "4 Juan 13 17 10" + ] + }, + "execution_count": 172, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data1.rename( columns = { \"Students\":'St', \"Math\":'Ma', \"English\":'En', \"Art\":'Ar'} )" + ] + }, + { + "cell_type": "code", + "execution_count": 173, + "metadata": {}, + "outputs": [], + "source": [ + "# Add column and index row name\n", + "data = {'state': ['Lima', 'Piura', 'Tumbes', 'Cuzco', 'Ica', 'Puno'],\n", + " 'year': [2000, 2001, 2002, 2001, 2002, 2003],\n", + " 'pop': [1.5, 1.7, 3.6, 2.4, 2.9, 3.2]}" + ] + }, + { + "cell_type": "code", + "execution_count": 174, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
yearstatepopdebt
one2000Lima1.5NaN
two2001Piura1.7NaN
three2002Tumbes3.6NaN
four2001Cuzco2.4NaN
five2002Ica2.9NaN
six2003Puno3.2NaN
\n", + "
" + ], + "text/plain": [ + " year state pop debt\n", + "one 2000 Lima 1.5 NaN\n", + "two 2001 Piura 1.7 NaN\n", + "three 2002 Tumbes 3.6 NaN\n", + "four 2001 Cuzco 2.4 NaN\n", + "five 2002 Ica 2.9 NaN\n", + "six 2003 Puno 3.2 NaN" + ] + }, + "execution_count": 174, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "frame = pd.DataFrame(data, \n", + " columns=[\"year\", 'state', 'pop', 'debt'] ,\n", + " index=['one', 'two', 'three', 'four','five', 'six'] )\n", + "\n", + "frame" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load files : CSV, Excel" + ] + }, + { + "cell_type": "code", + "execution_count": 124, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "C:\\Users\\melor\\OneDrive\\Documentos\\GitHub\\Python for Data Science\n" + ] + } + ], + "source": [ + "import os\n", + "import os\n", + "print(os.getcwd()) # Muestra la carpeta actual\n" + ] + }, + { + "cell_type": "code", + "execution_count": 182, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Unnamed: 0wagelwagesexshshsgsclclgadmw...weneexp1exp2exp3exp4occocc2indind2
0109.6153852.2633641000100...017.00.490.3430.2401360011837018
11248.0769233.8728020000100...0131.09.6129.79192.352130501050709
21511.0576922.4031260010000...0118.03.245.83210.49766260197704
31813.9423082.6349281000010...0125.06.2515.62539.06254201699012
41928.8461543.3619771000100...0122.04.8410.64823.425620156947022
\n", + "

5 rows × 21 columns

\n", + "
" + ], + "text/plain": [ + " Unnamed: 0 wage lwage sex shs hsg scl clg ad mw ... we \\\n", + "0 10 9.615385 2.263364 1 0 0 0 1 0 0 ... 0 \n", + "1 12 48.076923 3.872802 0 0 0 0 1 0 0 ... 0 \n", + "2 15 11.057692 2.403126 0 0 1 0 0 0 0 ... 0 \n", + "3 18 13.942308 2.634928 1 0 0 0 0 1 0 ... 0 \n", + "4 19 28.846154 3.361977 1 0 0 0 1 0 0 ... 0 \n", + "\n", + " ne exp1 exp2 exp3 exp4 occ occ2 ind ind2 \n", + "0 1 7.0 0.49 0.343 0.2401 3600 11 8370 18 \n", + "1 1 31.0 9.61 29.791 92.3521 3050 10 5070 9 \n", + "2 1 18.0 3.24 5.832 10.4976 6260 19 770 4 \n", + "3 1 25.0 6.25 15.625 39.0625 420 1 6990 12 \n", + "4 1 22.0 4.84 10.648 23.4256 2015 6 9470 22 \n", + "\n", + "[5 rows x 21 columns]" + ] + }, + "execution_count": 182, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#using relative path\n", + "#import pandas as pd\n", + "#r'..\\data\\base1.xlsx'\n", + "base0 = pd.read_excel(r'./data/base1.xlsx', sheet_name = \"data\")\n", + "\n", + "print(type(base0))\n", + "base0.head()\n", + "\n", + "#base0.to_csv(r'./data/base.csv')" + ] + }, + { + "cell_type": "code", + "execution_count": 250, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Unnamed: 0wagelwagesexshshsgsclclgadmw...weneexp1exp2exp3exp4occocc2indind2
0109.6153852.2633641000100...017.00.490.3430.24013600.0118370.018
11248.0769233.8728020000100...0131.09.6129.79192.35213050.0105070.09
21511.0576922.4031260010000...0118.03.245.83210.49766260.019770.04
31813.9423082.6349281000010...0125.06.2515.62539.0625420.016990.012
41928.8461543.3619771000100...0122.04.8410.64823.42562015.069470.022
..................................................................
51453262014.7692312.6925460000100...109.00.810.7290.65614700.0164970.09
51463262423.0769233.1388331001000...1012.01.441.7282.07364110.0138680.020
51473262638.4615383.6496590000010...1011.01.211.3311.46411550.043680.06
51483263132.9670333.4955080010000...1010.01.001.0001.00002920.096570.011
51493264317.3076922.8511510000010...1014.01.962.7443.84161610.057460.014
\n", + "

5150 rows × 21 columns

\n", + "
" + ], + "text/plain": [ + " Unnamed: 0 wage lwage sex shs hsg scl clg ad mw ... \\\n", + "0 10 9.615385 2.263364 1 0 0 0 1 0 0 ... \n", + "1 12 48.076923 3.872802 0 0 0 0 1 0 0 ... \n", + "2 15 11.057692 2.403126 0 0 1 0 0 0 0 ... \n", + "3 18 13.942308 2.634928 1 0 0 0 0 1 0 ... \n", + "4 19 28.846154 3.361977 1 0 0 0 1 0 0 ... \n", + "... ... ... ... ... ... ... ... ... .. .. ... \n", + "5145 32620 14.769231 2.692546 0 0 0 0 1 0 0 ... \n", + "5146 32624 23.076923 3.138833 1 0 0 1 0 0 0 ... \n", + "5147 32626 38.461538 3.649659 0 0 0 0 0 1 0 ... \n", + "5148 32631 32.967033 3.495508 0 0 1 0 0 0 0 ... \n", + "5149 32643 17.307692 2.851151 0 0 0 0 0 1 0 ... \n", + "\n", + " we ne exp1 exp2 exp3 exp4 occ occ2 ind ind2 \n", + "0 0 1 7.0 0.49 0.343 0.2401 3600.0 11 8370.0 18 \n", + "1 0 1 31.0 9.61 29.791 92.3521 3050.0 10 5070.0 9 \n", + "2 0 1 18.0 3.24 5.832 10.4976 6260.0 19 770.0 4 \n", + "3 0 1 25.0 6.25 15.625 39.0625 420.0 1 6990.0 12 \n", + "4 0 1 22.0 4.84 10.648 23.4256 2015.0 6 9470.0 22 \n", + "... .. .. ... ... ... ... ... ... ... ... \n", + "5145 1 0 9.0 0.81 0.729 0.6561 4700.0 16 4970.0 9 \n", + "5146 1 0 12.0 1.44 1.728 2.0736 4110.0 13 8680.0 20 \n", + "5147 1 0 11.0 1.21 1.331 1.4641 1550.0 4 3680.0 6 \n", + "5148 1 0 10.0 1.00 1.000 1.0000 2920.0 9 6570.0 11 \n", + "5149 1 0 14.0 1.96 2.744 3.8416 1610.0 5 7460.0 14 \n", + "\n", + "[5150 rows x 21 columns]" + ] + }, + "execution_count": 250, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\n", + "base1 = pd.read_csv( r'./data/base0.csv')\n", + "base1" + ] + }, + { + "cell_type": "code", + "execution_count": 303, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 5150 entries, 0 to 5149\n", + "Data columns (total 5 columns):\n", + " # Column Non-Null Count Dtype \n", + "--- ------ -------------- ----- \n", + " 0 salario 5150 non-null float64\n", + " 1 lwage 5150 non-null float64\n", + " 2 sex 5150 non-null int64 \n", + " 3 exp1 5150 non-null float64\n", + " 4 ind 5150 non-null float64\n", + "dtypes: float64(4), int64(1)\n", + "memory usage: 201.3 KB\n" + ] + } + ], + "source": [ + "base1.info()\n", + "#base1.dtypes" + ] + }, + { + "cell_type": "code", + "execution_count": 252, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idsalariolwagesexshshsgsclclgadmw...weneexp1exp2exp3exp4occocc2indind2
0109.6153852.2633641000100...017.00.490.3430.24013600.0118370.018
11248.0769233.8728020000100...0131.09.6129.79192.35213050.0105070.09
21511.0576922.4031260010000...0118.03.245.83210.49766260.019770.04
31813.9423082.6349281000010...0125.06.2515.62539.0625420.016990.012
41928.8461543.3619771000100...0122.04.8410.64823.42562015.069470.022
..................................................................
51453262014.7692312.6925460000100...109.00.810.7290.65614700.0164970.09
51463262423.0769233.1388331001000...1012.01.441.7282.07364110.0138680.020
51473262638.4615383.6496590000010...1011.01.211.3311.46411550.043680.06
51483263132.9670333.4955080010000...1010.01.001.0001.00002920.096570.011
51493264317.3076922.8511510000010...1014.01.962.7443.84161610.057460.014
\n", + "

5150 rows × 21 columns

\n", + "
" + ], + "text/plain": [ + " id salario lwage sex shs hsg scl clg ad mw ... we \\\n", + "0 10 9.615385 2.263364 1 0 0 0 1 0 0 ... 0 \n", + "1 12 48.076923 3.872802 0 0 0 0 1 0 0 ... 0 \n", + "2 15 11.057692 2.403126 0 0 1 0 0 0 0 ... 0 \n", + "3 18 13.942308 2.634928 1 0 0 0 0 1 0 ... 0 \n", + "4 19 28.846154 3.361977 1 0 0 0 1 0 0 ... 0 \n", + "... ... ... ... ... ... ... ... ... .. .. ... .. \n", + "5145 32620 14.769231 2.692546 0 0 0 0 1 0 0 ... 1 \n", + "5146 32624 23.076923 3.138833 1 0 0 1 0 0 0 ... 1 \n", + "5147 32626 38.461538 3.649659 0 0 0 0 0 1 0 ... 1 \n", + "5148 32631 32.967033 3.495508 0 0 1 0 0 0 0 ... 1 \n", + "5149 32643 17.307692 2.851151 0 0 0 0 0 1 0 ... 1 \n", + "\n", + " ne exp1 exp2 exp3 exp4 occ occ2 ind ind2 \n", + "0 1 7.0 0.49 0.343 0.2401 3600.0 11 8370.0 18 \n", + "1 1 31.0 9.61 29.791 92.3521 3050.0 10 5070.0 9 \n", + "2 1 18.0 3.24 5.832 10.4976 6260.0 19 770.0 4 \n", + "3 1 25.0 6.25 15.625 39.0625 420.0 1 6990.0 12 \n", + "4 1 22.0 4.84 10.648 23.4256 2015.0 6 9470.0 22 \n", + "... .. ... ... ... ... ... ... ... ... \n", + "5145 0 9.0 0.81 0.729 0.6561 4700.0 16 4970.0 9 \n", + "5146 0 12.0 1.44 1.728 2.0736 4110.0 13 8680.0 20 \n", + "5147 0 11.0 1.21 1.331 1.4641 1550.0 4 3680.0 6 \n", + "5148 0 10.0 1.00 1.000 1.0000 2920.0 9 6570.0 11 \n", + "5149 0 14.0 1.96 2.744 3.8416 1610.0 5 7460.0 14 \n", + "\n", + "[5150 rows x 21 columns]" + ] + }, + "execution_count": 252, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "base1 = base1.rename( columns = { \"wage\":'salario', \"Unnamed: 0\":'id'} )\n", + "base1" + ] + }, + { + "cell_type": "code", + "execution_count": 253, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
salariolwagesexshshsgsclclgadmwsoweneexp1exp2exp3exp4occocc2ind
09.6153852.26336410001000017.00.490.3430.24013600.0118370.0
148.0769233.872802000010000131.09.6129.79192.35213050.0105070.0
211.0576922.403126001000000118.03.245.83210.49766260.019770.0
313.9423082.634928100001000125.06.2515.62539.0625420.016990.0
428.8461543.361977100010000122.04.8410.64823.42562015.069470.0
............................................................
514514.7692312.69254600001000109.00.810.7290.65614700.0164970.0
514623.0769233.138833100100001012.01.441.7282.07364110.0138680.0
514738.4615383.649659000001001011.01.211.3311.46411550.043680.0
514832.9670333.495508001000001010.01.001.0001.00002920.096570.0
514917.3076922.851151000001001014.01.962.7443.84161610.057460.0
\n", + "

5150 rows × 19 columns

\n", + "
" + ], + "text/plain": [ + " salario lwage sex shs hsg scl clg ad mw so we ne exp1 \\\n", + "0 9.615385 2.263364 1 0 0 0 1 0 0 0 0 1 7.0 \n", + "1 48.076923 3.872802 0 0 0 0 1 0 0 0 0 1 31.0 \n", + "2 11.057692 2.403126 0 0 1 0 0 0 0 0 0 1 18.0 \n", + "3 13.942308 2.634928 1 0 0 0 0 1 0 0 0 1 25.0 \n", + "4 28.846154 3.361977 1 0 0 0 1 0 0 0 0 1 22.0 \n", + "... ... ... ... ... ... ... ... .. .. .. .. .. ... \n", + "5145 14.769231 2.692546 0 0 0 0 1 0 0 0 1 0 9.0 \n", + "5146 23.076923 3.138833 1 0 0 1 0 0 0 0 1 0 12.0 \n", + "5147 38.461538 3.649659 0 0 0 0 0 1 0 0 1 0 11.0 \n", + "5148 32.967033 3.495508 0 0 1 0 0 0 0 0 1 0 10.0 \n", + "5149 17.307692 2.851151 0 0 0 0 0 1 0 0 1 0 14.0 \n", + "\n", + " exp2 exp3 exp4 occ occ2 ind \n", + "0 0.49 0.343 0.2401 3600.0 11 8370.0 \n", + "1 9.61 29.791 92.3521 3050.0 10 5070.0 \n", + "2 3.24 5.832 10.4976 6260.0 19 770.0 \n", + "3 6.25 15.625 39.0625 420.0 1 6990.0 \n", + "4 4.84 10.648 23.4256 2015.0 6 9470.0 \n", + "... ... ... ... ... ... ... \n", + "5145 0.81 0.729 0.6561 4700.0 16 4970.0 \n", + "5146 1.44 1.728 2.0736 4110.0 13 8680.0 \n", + "5147 1.21 1.331 1.4641 1550.0 4 3680.0 \n", + "5148 1.00 1.000 1.0000 2920.0 9 6570.0 \n", + "5149 1.96 2.744 3.8416 1610.0 5 7460.0 \n", + "\n", + "[5150 rows x 19 columns]" + ] + }, + "execution_count": 253, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "base1 = base1.drop([\"id\",\"ind2\"], axis=1)\n", + "base1\n", + "# axis 1 : columns\n", + "# axis 0 : rows" + ] + }, + { + "cell_type": "code", + "execution_count": 254, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
salariolwagesexexp1ind
09.6153852.26336417.08370.0
148.0769233.872802031.05070.0
211.0576922.403126018.0770.0
313.9423082.634928125.06990.0
428.8461543.361977122.09470.0
..................
514514.7692312.69254609.04970.0
514623.0769233.138833112.08680.0
514738.4615383.649659011.03680.0
514832.9670333.495508010.06570.0
514917.3076922.851151014.07460.0
\n", + "

5150 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " salario lwage sex exp1 ind\n", + "0 9.615385 2.263364 1 7.0 8370.0\n", + "1 48.076923 3.872802 0 31.0 5070.0\n", + "2 11.057692 2.403126 0 18.0 770.0\n", + "3 13.942308 2.634928 1 25.0 6990.0\n", + "4 28.846154 3.361977 1 22.0 9470.0\n", + "... ... ... ... ... ...\n", + "5145 14.769231 2.692546 0 9.0 4970.0\n", + "5146 23.076923 3.138833 1 12.0 8680.0\n", + "5147 38.461538 3.649659 0 11.0 3680.0\n", + "5148 32.967033 3.495508 0 10.0 6570.0\n", + "5149 17.307692 2.851151 0 14.0 7460.0\n", + "\n", + "[5150 rows x 5 columns]" + ] + }, + "execution_count": 254, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "base1 = base1.drop([\"we\",\"exp2\",\"exp3\",\"exp4\",\"occ\",\"occ2\",\"shs\",\"hsg\",\"scl\",\"clg\",\"ad\",\"mw\",\"so\",\"ne\"], axis=1)\n", + "base1" + ] + }, + { + "cell_type": "code", + "execution_count": 255, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
salariolwagesexexp1ind
09.6153852.26336417.08370.0
211.0576922.403126018.0770.0
428.8461543.361977122.09470.0
511.7307692.46221511.07460.0
619.2307692.956512142.07280.0
..................
514514.7692312.69254609.04970.0
514623.0769233.138833112.08680.0
514738.4615383.649659011.03680.0
514832.9670333.495508010.06570.0
514917.3076922.851151014.07460.0
\n", + "

5148 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " salario lwage sex exp1 ind\n", + "0 9.615385 2.263364 1 7.0 8370.0\n", + "2 11.057692 2.403126 0 18.0 770.0\n", + "4 28.846154 3.361977 1 22.0 9470.0\n", + "5 11.730769 2.462215 1 1.0 7460.0\n", + "6 19.230769 2.956512 1 42.0 7280.0\n", + "... ... ... ... ... ...\n", + "5145 14.769231 2.692546 0 9.0 4970.0\n", + "5146 23.076923 3.138833 1 12.0 8680.0\n", + "5147 38.461538 3.649659 0 11.0 3680.0\n", + "5148 32.967033 3.495508 0 10.0 6570.0\n", + "5149 17.307692 2.851151 0 14.0 7460.0\n", + "\n", + "[5148 rows x 5 columns]" + ] + }, + "execution_count": 255, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# row 1 and 3\n", + "base1.drop([1,3], axis = 0)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Slicing dataframe " + ] + }, + { + "cell_type": "code", + "execution_count": 256, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
salariolwagesexexp1ind
09.6153852.26336417.08370.0
148.0769233.872802031.05070.0
211.0576922.403126018.0770.0
313.9423082.634928125.06990.0
428.8461543.361977122.09470.0
511.7307692.46221511.07460.0
\n", + "
" + ], + "text/plain": [ + " salario lwage sex exp1 ind\n", + "0 9.615385 2.263364 1 7.0 8370.0\n", + "1 48.076923 3.872802 0 31.0 5070.0\n", + "2 11.057692 2.403126 0 18.0 770.0\n", + "3 13.942308 2.634928 1 25.0 6990.0\n", + "4 28.846154 3.361977 1 22.0 9470.0\n", + "5 11.730769 2.462215 1 1.0 7460.0" + ] + }, + "execution_count": 256, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#select rows using positions\n", + "base1.iloc[0:6]" + ] + }, + { + "cell_type": "code", + "execution_count": 235, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
salariolwage
09.6153852.263364
148.0769233.872802
211.0576922.403126
313.9423082.634928
428.8461543.361977
.........
514514.7692312.692546
514623.0769233.138833
514738.4615383.649659
514832.9670333.495508
514917.3076922.851151
\n", + "

5150 rows × 2 columns

\n", + "
" + ], + "text/plain": [ + " salario lwage\n", + "0 9.615385 2.263364\n", + "1 48.076923 3.872802\n", + "2 11.057692 2.403126\n", + "3 13.942308 2.634928\n", + "4 28.846154 3.361977\n", + "... ... ...\n", + "5145 14.769231 2.692546\n", + "5146 23.076923 3.138833\n", + "5147 38.461538 3.649659\n", + "5148 32.967033 3.495508\n", + "5149 17.307692 2.851151\n", + "\n", + "[5150 rows x 2 columns]" + ] + }, + "execution_count": 235, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# row index and columns names \n", + "\n", + "base1.loc[:,['salario', 'lwage']]" + ] + }, + { + "cell_type": "code", + "execution_count": 236, + "metadata": {}, + "outputs": [], + "source": [ + "base3 = base1[['lwage','salario']]" + ] + }, + { + "cell_type": "code", + "execution_count": 237, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
lwagesalario
02.2633649.615385
13.87280248.076923
22.40312611.057692
32.63492813.942308
43.36197728.846154
.........
51452.69254614.769231
51463.13883323.076923
51473.64965938.461538
51483.49550832.967033
51492.85115117.307692
\n", + "

5150 rows × 2 columns

\n", + "
" + ], + "text/plain": [ + " lwage salario\n", + "0 2.263364 9.615385\n", + "1 3.872802 48.076923\n", + "2 2.403126 11.057692\n", + "3 2.634928 13.942308\n", + "4 3.361977 28.846154\n", + "... ... ...\n", + "5145 2.692546 14.769231\n", + "5146 3.138833 23.076923\n", + "5147 3.649659 38.461538\n", + "5148 3.495508 32.967033\n", + "5149 2.851151 17.307692\n", + "\n", + "[5150 rows x 2 columns]" + ] + }, + "execution_count": 237, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "base3" + ] + }, + { + "cell_type": "code", + "execution_count": 196, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
yearstatepopdebt
one2000Lima1.5NaN
two2001Piura1.7NaN
\n", + "
" + ], + "text/plain": [ + " year state pop debt\n", + "one 2000 Lima 1.5 NaN\n", + "two 2001 Piura 1.7 NaN" + ] + }, + "execution_count": 196, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#frame.loc[['one','two']] #selecion for labels \n", + "\n", + "#frame.iloc[0:2] #selection for numbers of rows" + ] + }, + { + "cell_type": "code", + "execution_count": 238, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
salariolwagesexexp1exp2ind
09.6153852.26336417.00.498370.0
313.9423082.634928125.06.256990.0
428.8461543.361977122.04.849470.0
511.7307692.46221511.00.017460.0
619.2307692.956512142.017.647280.0
.....................
513713.4615382.59983718.00.648590.0
513819.7115382.98120418.00.648090.0
514045.5465593.81873515.00.258190.0
514324.0384623.179655117.02.899480.0
514623.0769233.138833112.01.448680.0
\n", + "

2289 rows × 6 columns

\n", + "
" + ], + "text/plain": [ + " salario lwage sex exp1 exp2 ind\n", + "0 9.615385 2.263364 1 7.0 0.49 8370.0\n", + "3 13.942308 2.634928 1 25.0 6.25 6990.0\n", + "4 28.846154 3.361977 1 22.0 4.84 9470.0\n", + "5 11.730769 2.462215 1 1.0 0.01 7460.0\n", + "6 19.230769 2.956512 1 42.0 17.64 7280.0\n", + "... ... ... ... ... ... ...\n", + "5137 13.461538 2.599837 1 8.0 0.64 8590.0\n", + "5138 19.711538 2.981204 1 8.0 0.64 8090.0\n", + "5140 45.546559 3.818735 1 5.0 0.25 8190.0\n", + "5143 24.038462 3.179655 1 17.0 2.89 9480.0\n", + "5146 23.076923 3.138833 1 12.0 1.44 8680.0\n", + "\n", + "[2289 rows x 6 columns]" + ] + }, + "execution_count": 238, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "base1[base1['sex']==1]" + ] + }, + { + "cell_type": "code", + "execution_count": 239, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
salariolwagesexexp1exp2ind
148.0769233.872802031.09.61005070.0
211.0576922.403126018.03.2400770.0
313.9423082.634928125.06.25006990.0
428.8461543.361977122.04.84009470.0
619.2307692.956512142.017.64007280.0
719.2307692.956512037.013.69005680.0
812.0000002.484907131.09.61008590.0
1112.0192312.486508030.09.00008270.0
1313.4615382.599837120.54.20258190.0
1416.3461542.793993125.06.25007870.0
\n", + "
" + ], + "text/plain": [ + " salario lwage sex exp1 exp2 ind\n", + "1 48.076923 3.872802 0 31.0 9.6100 5070.0\n", + "2 11.057692 2.403126 0 18.0 3.2400 770.0\n", + "3 13.942308 2.634928 1 25.0 6.2500 6990.0\n", + "4 28.846154 3.361977 1 22.0 4.8400 9470.0\n", + "6 19.230769 2.956512 1 42.0 17.6400 7280.0\n", + "7 19.230769 2.956512 0 37.0 13.6900 5680.0\n", + "8 12.000000 2.484907 1 31.0 9.6100 8590.0\n", + "11 12.019231 2.486508 0 30.0 9.0000 8270.0\n", + "13 13.461538 2.599837 1 20.5 4.2025 8190.0\n", + "14 16.346154 2.793993 1 25.0 6.2500 7870.0" + ] + }, + "execution_count": 239, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "base1[base1.exp1 > 10].head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 240, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
salariolwagesexexp1exp2ind
511.7307692.46221511.00.01007460.0
919.2307692.95651214.00.16008190.0
178.6538462.15800403.50.1225570.0
2712.0000002.48490704.50.2025770.0
3042.3076923.74496910.00.00004795.0
.....................
511015.8653852.76414010.00.00008180.0
511418.7500002.93119412.00.04008370.0
511520.9134623.04039314.50.20258470.0
511812.0192312.48650804.00.16006170.0
512115.8653852.76414002.00.04007870.0
\n", + "

1058 rows × 6 columns

\n", + "
" + ], + "text/plain": [ + " salario lwage sex exp1 exp2 ind\n", + "5 11.730769 2.462215 1 1.0 0.0100 7460.0\n", + "9 19.230769 2.956512 1 4.0 0.1600 8190.0\n", + "17 8.653846 2.158004 0 3.5 0.1225 570.0\n", + "27 12.000000 2.484907 0 4.5 0.2025 770.0\n", + "30 42.307692 3.744969 1 0.0 0.0000 4795.0\n", + "... ... ... ... ... ... ...\n", + "5110 15.865385 2.764140 1 0.0 0.0000 8180.0\n", + "5114 18.750000 2.931194 1 2.0 0.0400 8370.0\n", + "5115 20.913462 3.040393 1 4.5 0.2025 8470.0\n", + "5118 12.019231 2.486508 0 4.0 0.1600 6170.0\n", + "5121 15.865385 2.764140 0 2.0 0.0400 7870.0\n", + "\n", + "[1058 rows x 6 columns]" + ] + }, + "execution_count": 240, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "base1[base1.exp1 < 5]" + ] + }, + { + "cell_type": "code", + "execution_count": 241, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
salariolwagesexexp1exp2ind
313.9423082.634928125.06.25006990.0
428.8461543.361977122.04.84009470.0
619.2307692.956512142.017.64007280.0
812.0000002.484907131.09.61008590.0
1313.4615382.599837120.54.20258190.0
1416.3461542.793993125.06.25007870.0
2217.7884622.878550111.01.21007860.0
2416.3043482.791432124.56.00255480.0
3113.9423082.634928115.52.40254670.0
3314.0532542.642854114.01.96007860.0
\n", + "
" + ], + "text/plain": [ + " salario lwage sex exp1 exp2 ind\n", + "3 13.942308 2.634928 1 25.0 6.2500 6990.0\n", + "4 28.846154 3.361977 1 22.0 4.8400 9470.0\n", + "6 19.230769 2.956512 1 42.0 17.6400 7280.0\n", + "8 12.000000 2.484907 1 31.0 9.6100 8590.0\n", + "13 13.461538 2.599837 1 20.5 4.2025 8190.0\n", + "14 16.346154 2.793993 1 25.0 6.2500 7870.0\n", + "22 17.788462 2.878550 1 11.0 1.2100 7860.0\n", + "24 16.304348 2.791432 1 24.5 6.0025 5480.0\n", + "31 13.942308 2.634928 1 15.5 2.4025 4670.0\n", + "33 14.053254 2.642854 1 14.0 1.9600 7860.0" + ] + }, + "execution_count": 241, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "base1[(base1['sex']==1) & (base1.exp1 > 10) ].head(10) #and\n", + "#base1[(base1['sex']==1) | (base1.exp1 > 10) ].head(10) #or" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# If condition\n", + "\n", + "Function **if** test conditions. \n", + "- Equals: a == b\n", + "- Not Equals: a != b\n", + "- Less than: a < b\n", + "- Less than or equal to: a <= b\n", + "- Greater than: a > b\n", + "- Greater than or equal to: a >= b\n", + "\n", + "\"image" + ] + }, + { + "cell_type": "code", + "execution_count": 201, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Test expresion 4 is True\n" + ] + } + ], + "source": [ + "A = 20\n", + "B = 30\n", + "\n", + "if A == B:\n", + " print( 'Test expresion 1 is True' )\n", + " \n", + "elif A > B:\n", + " print( 'Test expresion 2 is True' )\n", + "\n", + "elif A >= B:\n", + " print( 'Test expresion 3 is True' )\n", + " \n", + "elif A < B:\n", + " print( 'Test expresion 4 is True' )\n", + " \n", + "elif A <= B:\n", + " print( 'Test expresion 5 is True' )\n", + " \n", + "else:\n", + " print( 'Test expresion 6 is True' )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# For Loops\n", + "\n", + "A for loop is used for iterating over a sequence. It has the following structure:\n", + "\n", + "\"image\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 147, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,\n", + " 18, 19])" + ] + }, + "execution_count": 147, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "secuencia = np.arange(1,20)\n", + "secuencia" + ] + }, + { + "cell_type": "code", + "execution_count": 150, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "numero 1\n", + "numero 2\n", + "numero 3\n", + "numero 4\n", + "numero 5\n", + "numero 6\n", + "numero 7\n", + "numero 8\n", + "numero 9\n", + "numero 10\n", + "numero 11\n", + "numero 12\n", + "numero 13\n", + "numero 14\n", + "numero 15\n", + "numero 16\n", + "numero 17\n", + "numero 18\n", + "numero 19\n" + ] + } + ], + "source": [ + "secuencia = np.arange(1,20)\n", + "\n", + "for i in secuencia:\n", + " print(\"numero\",i)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 156, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Laptop: Precio original $1200, con descuento $1080.00\n", + "Celular: Precio original $800, con descuento $720.00\n", + "Tablet: Precio original $500, con descuento $450.00\n", + "Monitor: Precio original $300, con descuento $270.00\n" + ] + } + ], + "source": [ + "productos = [\"Laptop\", \"Celular\", \"Tablet\", \"Monitor\"]\n", + "precios = [1200, 800, 500, 300]\n", + "\n", + "for i in range(len(productos)):\n", + " descuento = precios[i] * 0.10 # 10% de descuento\n", + " nuevo_precio = precios[i] - descuento\n", + " print(f\"{productos[i]}: Precio original ${precios[i]}, con descuento ${nuevo_precio:.2f}\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 206, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "📜 Registro de Calificaciones:\n", + "--------------------------------------------------\n", + "🧑‍🎓 Miguel | Nota: 16 | Semestre: 2018-1 | 🎉 ✅ Aprobó\n", + "🧑‍🎓 Anthony | Nota: 10 | Semestre: 2018-2 | ❌ Reprobó\n", + "🧑‍🎓 Paul | Nota: 14 | Semestre: 2019-1 | 🎉 ✅ Aprobó\n", + "🧑‍🎓 Rodrigo | Nota: 8 | Semestre: 2019-2 | ❌ Reprobó\n", + "🧑‍🎓 Jason | Nota: 12 | Semestre: 2020-1 | 🎉 ✅ Aprobó\n", + "--------------------------------------------------\n", + "🎯 Para aprobar, se necesita una nota mínima de 11.\n" + ] + } + ], + "source": [ + "# Lista de estudiantes\n", + "students = ['Miguel', 'Anthony', 'Paul', 'Rodrigo', 'Jason']\n", + "\n", + "# Lista de notas\n", + "grades = [16, 10, 14, 8, 12] # Notas de los estudiantes\n", + "\n", + "# Lista de semestres en los que se matricularon\n", + "semesters = [\"2023-1\", \"2023-2\", \"2024-1\", \"2024-2\", \"2025-1\"]\n", + "\n", + "print(\"📜 Registro de Calificaciones:\")\n", + "print(\"-\" * 50)\n", + "\n", + "# Recorrer las listas al mismo tiempo\n", + "for student, grade, sem in zip(students, grades, semesters):\n", + " status = \"🎉 ✅ Aprobó\" if grade >= 11 else \"❌ Reprobó\"\n", + " print(f\"🧑‍🎓 {student} | Nota: {grade} | Semestre: {sem} | {status}\")\n", + "\n", + "print(\"-\" * 50)\n", + "print(\"🎯 Para aprobar, se necesita una nota mínima de 11.\")\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Functions\n", + "\n", + "- `Arguments` − Elements that the function will use to make operations. Arguments are optional and can have default values.\n", + "\n", + "- `Function Body` − This defines what your function does.\n", + "- `return` − Specifies the variable that will be the output of the function.\n", + "\n", + "Return Value − The return value of a function is the last expression in the function body to be evaluated.\n", + "

\n", + "\n", + "def function_name (arg_1, arg_2, ...) :

\n", + "    Function body
\n", + "
    return result
\n", + "
" + ] + }, + { + "cell_type": "code", + "execution_count": 207, + "metadata": {}, + "outputs": [], + "source": [ + "def suma(x, y):\n", + " mate = (x + y)*15\n", + " return mate" + ] + }, + { + "cell_type": "code", + "execution_count": 208, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "210" + ] + }, + "execution_count": 208, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "suma(10,4)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "El precio con descuento es: $135.00\n" + ] + } + ], + "source": [ + "def calcular_descuento(precio, descuento):\n", + " precio_final = precio - (precio * descuento / 100)\n", + " return precio_final\n", + "\n", + "producto = 150 # Precio en dólares\n", + "descuento = 10 # 10% de descuento\n", + "\n", + "precio_con_descuento = calcular_descuento(producto, descuento)\n", + "print(f\"El precio con descuento es: ${precio_con_descuento:.2f}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Ana es un Cliente VIP (gastó $1200).\n", + "Carlos es un Cliente Regular (gastó $700).\n", + "Elena es un Cliente Nuevo (gastó $300).\n", + "Luis es un Cliente VIP (gastó $1500).\n", + "Marta es un Cliente Regular (gastó $800).\n" + ] + } + ], + "source": [ + "def clasificar_cliente(gasto):\n", + " \"\"\"Clasifica un cliente según su gasto total.\"\"\"\n", + " if gasto > 1000:\n", + " return \"Cliente VIP\"\n", + " elif gasto >= 500:\n", + " return \"Cliente Regular\"\n", + " else:\n", + " return \"Cliente Nuevo\"\n", + "\n", + "# Lista de clientes con sus compras totales\n", + "clientes = [\n", + " {\"nombre\": \"Ana\", \"gasto\": 1200},\n", + " {\"nombre\": \"Carlos\", \"gasto\": 700},\n", + " {\"nombre\": \"Elena\", \"gasto\": 300},\n", + " {\"nombre\": \"Luis\", \"gasto\": 1500},\n", + " {\"nombre\": \"Marta\", \"gasto\": 800}\n", + "]\n", + "\n", + "# Clasificar clientes y mostrar resultados\n", + "for cliente in clientes:\n", + " categoria = clasificar_cliente(cliente[\"gasto\"])\n", + " print(f\"{cliente['nombre']} es un {categoria} (gastó ${cliente['gasto']}).\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "📦 El producto 'Aceite Primor' tiene ventas Baja (8000 unidades).\n", + "📦 El producto 'Harina Blanca Flor' tiene ventas Media (30000 unidades).\n", + "📦 El producto 'Galletas Casino' tiene ventas Alta (70000 unidades).\n" + ] + } + ], + "source": [ + "def clasificar_producto(nombre, ventas):\n", + " \"\"\"Clasifica un producto de Alicorp según sus ventas.\"\"\"\n", + " if ventas < 10000:\n", + " categoria = \"Baja\"\n", + " elif ventas <= 50000: #más condiciones cuando if no es verdader\n", + " categoria = \"Media\"\n", + " else: #Ejecuta esto si no se cumplen las condiciones anteriores\n", + " categoria = \"Alta\"\n", + "\n", + " return f\"📦 El producto '{nombre}' tiene ventas {categoria} ({ventas} unidades).\"\n", + "\n", + "# Prueba con productos de Alicorp\n", + "productos = [\n", + " (\"Aceite Primor\", 8000),\n", + " (\"Harina Blanca Flor\", 30000),\n", + " (\"Galletas Casino\", 70000)\n", + "]\n", + "\n", + "for producto, ventas in productos:\n", + " print(clasificar_producto(producto, ventas))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "✅ Rentable: Ganancia de $5,000,000.00\n" + ] + } + ], + "source": [ + "def es_rentable(toneladas, precio_por_tonelada, costo_operacional):\n", + " \"\"\"Determina si la extracción de cobre en Las Bambas es rentable.\"\"\"\n", + " ingresos = toneladas * precio_por_tonelada\n", + " ganancia = ingresos - costo_operacional\n", + "\n", + " if ganancia > 0:\n", + " return f\"✅ Rentable: Ganancia de ${ganancia:,.2f}\"\n", + " else:\n", + " return f\"❌ No rentable: Pérdida de ${abs(ganancia):,.2f}\"\n", + "\n", + "# Prueba con valores de Las Bambas\n", + "toneladas_extraidas = 5000\n", + "precio_cobre = 9000 # Precio por tonelada en dólares\n", + "costo_operacional = 40000000 # Costos totales\n", + "\n", + "resultado = es_rentable(toneladas_extraidas, precio_cobre, costo_operacional)\n", + "print(resultado)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "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.7.1" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/Labs/Python_Notebooks/LAB1/Python_tutorial.ipynb b/Labs/Python_Notebooks/LAB1/Python_tutorial.ipynb index 82cfcd83f..f237f8e18 100644 --- a/Labs/Python_Notebooks/LAB1/Python_tutorial.ipynb +++ b/Labs/Python_Notebooks/LAB1/Python_tutorial.ipynb @@ -40,7 +40,29 @@ }, { "cell_type": "code", - "execution_count": 265, + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: pandas in c:\\users\\pc\\.conda\\envs\\rstudio\\lib\\site-packages (1.3.5)Note: you may need to restart the kernel to use updated packages.\n", + "\n", + "Requirement already satisfied: numpy in c:\\users\\pc\\.conda\\envs\\rstudio\\lib\\site-packages (1.21.6)\n", + "Requirement already satisfied: pytz>=2017.3 in c:\\users\\pc\\.conda\\envs\\rstudio\\lib\\site-packages (from pandas) (2025.2)\n", + "Requirement already satisfied: python-dateutil>=2.7.3 in c:\\users\\pc\\.conda\\envs\\rstudio\\lib\\site-packages (from pandas) (2.8.2)\n", + "Requirement already satisfied: six>=1.5 in c:\\users\\pc\\.conda\\envs\\rstudio\\lib\\site-packages (from python-dateutil>=2.7.3->pandas) (1.16.0)\n" + ] + } + ], + "source": [ + "pip install pandas numpy" + ] + }, + { + "cell_type": "code", + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -68,7 +90,7 @@ }, { "cell_type": "code", - "execution_count": 269, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -77,14 +99,14 @@ "int" ] }, - "execution_count": 269, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Int type\n", - "edad = 25\n", + "edad = 22\n", "edad\n", "\n", "type(edad)" @@ -114,7 +136,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -123,7 +145,7 @@ "complex" ] }, - "execution_count": 14, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -136,7 +158,7 @@ }, { "cell_type": "code", - "execution_count": 271, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -145,7 +167,7 @@ "str" ] }, - "execution_count": 271, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -159,22 +181,23 @@ }, { "cell_type": "code", - "execution_count": 272, + "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'H'" + "'Hola'" ] }, - "execution_count": 272, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "mensaje[0]" + "mensaje[0:4]\n", + "#Slicing" ] }, { @@ -5000,7 +5023,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.7.1" } }, "nbformat": 4, diff --git a/Labs/Python_Notebooks/LAB2/.ipynb_checkpoints/Imbd_lab_students-checkpoint.ipynb b/Labs/Python_Notebooks/LAB2/.ipynb_checkpoints/Imbd_lab_students-checkpoint.ipynb new file mode 100644 index 000000000..9359e62a1 --- /dev/null +++ b/Labs/Python_Notebooks/LAB2/.ipynb_checkpoints/Imbd_lab_students-checkpoint.ipynb @@ -0,0 +1,421 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "5b238174", + "metadata": {}, + "source": [ + "# Web Scrapping: Selenium" + ] + }, + { + "cell_type": "markdown", + "id": "d4e3b17c", + "metadata": {}, + "source": [ + "## 1. Libraries" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "dc2d3ffc", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import time\n", + "\n", + "# Herramientas de Selenium\n", + "from selenium import webdriver\n", + "from selenium.webdriver.common.by import By\n", + "from selenium.webdriver.chrome.options import Options\n", + "from selenium.webdriver.support.ui import WebDriverWait\n", + "from selenium.webdriver.support import expected_conditions as EC\n", + "from selenium.common.exceptions import NoSuchElementException, TimeoutException\n" + ] + }, + { + "cell_type": "markdown", + "id": "5f8e0e4a", + "metadata": {}, + "source": [ + "## 2. Configuración e Inicialización del Navegador\n", + "\n", + "Aquí configuramos y lanzamos el navegador Chrome que será controlado por nuestro script. Dejamos que el Selenium Manager integrado se encargue de gestionar el chromedriver por nosotros, lo que simplifica mucho la configuración." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b2aaba9b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WebDriver iniciado con éxito.\n" + ] + } + ], + "source": [ + "# Configuramos las opciones de Chrome\n", + "chrome_options = Options()\n", + "# chrome_options.add_argument(\"--headless\")\n", + "chrome_options.add_argument(\"--start-maximized\")\n", + "chrome_options.add_argument(\"--lang=en-US\")\n", + "\n", + "# Iniciar el WebDriver de Chrome\n", + "# Pista: Crea una variable llamada 'driver' y asígnale la instancia de webdriver.Chrome(),\n", + "# pasando nuestras 'chrome_options' como argumento.\n", + "driver = # [...COMPLETA AQUÍ...]\n", + "\n", + "print(\"WebDriver iniciado con éxito.\")" + ] + }, + { + "cell_type": "markdown", + "id": "27f43e70", + "metadata": {}, + "source": [ + "## 3. Navegar a la Página de IMdb\n", + "\n", + "Navegamos a la URL del Top 250 de IMDb. El paso más importante aquí es usar WebDriverWait. Le decimos a Selenium que espere hasta 10 segundos a que la lista de películas sea visible en la página antes de intentar hacer cualquier cosa. Esto hace nuestro script robusto frente a conexiones lentas." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a92ee23e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Esperando a que la lista de películas cargue...\n", + "Lista de películas encontrada. Comenzando el scraping.\n" + ] + } + ], + "source": [ + "# URL del Top 250 de IMDb\n", + "url = \"https://www.imdb.com/chart/top/\"\n", + "\n", + "# Pista: El objeto 'driver' tiene un método para abrir una URL. ¿Cuál es?\n", + "# [...COMPLETA AQUÍ...]\n", + "\n", + "# Lista para guardar los datos de cada película\n", + "movies_data = []\n", + "\n", + "# Selector CSS para la lista que contiene todas las películas\n", + "movie_list_selector = \"ul.ipc-metadata-list\"\n", + "\n", + "try:\n", + " print(\"Esperando a que la lista de películas cargue...\")\n", + " \n", + " # Completa la espera para que el script se detenga hasta que la lista de películas sea visible.\n", + " # Pista: Usa EC.visibility_of_element_located() y pásale una tupla con el método de búsqueda (By) y el selector.\n", + " WebDriverWait(driver, 10).until(\n", + " EC.visibility_of_element_located(( # [...COMPLETA AQUÍ EL MÉTODO By Y EL SELECTOR...] ))\n", + " )\n", + " print(\"Lista de películas encontrada. ¡A scrapear!\")\n", + "\n", + "except TimeoutException:\n", + " print(\"Error: La lista de películas no cargó a tiempo. El script se detendrá.\")\n", + " driver.quit()" + ] + }, + { + "cell_type": "markdown", + "id": "98b449d3", + "metadata": {}, + "source": [ + "## 4. Bucle Principal de Scraping\n", + "\n", + "Este es el núcleo de nuestro scraper.\n", + "\n", + "- Localizamos todos los elementos <*li> que contienen la información de cada película.\n", + "- Iteramos sobre los primeros 50 elementos de esa lista.\n", + "- Dentro de cada <*li>, buscamos los datos específicos (rango, título, año, calificación y URL) usando selectores CSS.\n", + "- Usamos bloques try-except para cada atributo. Si un dato no se encuentra en una película, el script registrará \"No disponible\" y continuará, en lugar de detenerse por un error." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4d0d1eca", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "✅ Scraped: #1 The Shawshank Redemption\n", + "✅ Scraped: #2 The Godfather\n", + "✅ Scraped: #3 The Dark Knight\n", + "✅ Scraped: #4 The Godfather Part II\n", + "✅ Scraped: #5 12 Angry Men\n", + "✅ Scraped: #6 The Lord of the Rings: The Return of the King\n", + "✅ Scraped: #7 Schindler's List\n", + "✅ Scraped: #8 Pulp Fiction\n", + "✅ Scraped: #9 The Lord of the Rings: The Fellowship of the Ring\n", + "✅ Scraped: #10 The Good, the Bad and the Ugly\n", + "✅ Scraped: #11 Forrest Gump\n", + "✅ Scraped: #12 The Lord of the Rings: The Two Towers\n", + "✅ Scraped: #13 Fight Club\n", + "✅ Scraped: #14 Inception\n", + "✅ Scraped: #15 Star Wars: Episode V - The Empire Strikes Back\n", + "✅ Scraped: #16 The Matrix\n", + "✅ Scraped: #17 Goodfellas\n", + "✅ Scraped: #18 Interstellar\n", + "✅ Scraped: #19 One Flew Over the Cuckoo's Nest\n", + "✅ Scraped: #20 Se7en\n", + "✅ Scraped: #21 It's a Wonderful Life\n", + "✅ Scraped: #22 The Silence of the Lambs\n", + "✅ Scraped: #23 Seven Samurai\n", + "✅ Scraped: #24 Saving Private Ryan\n", + "✅ Scraped: #25 The Green Mile\n", + "✅ Scraped: #26 City of God\n", + "✅ Scraped: #27 Life Is Beautiful\n", + "✅ Scraped: #28 Terminator 2: Judgment Day\n", + "✅ Scraped: #29 Star Wars: Episode IV - A New Hope\n", + "✅ Scraped: #30 Back to the Future\n", + "✅ Scraped: #31 Spirited Away\n", + "✅ Scraped: #32 The Pianist\n", + "✅ Scraped: #33 Gladiator\n", + "✅ Scraped: #34 Parasite\n", + "✅ Scraped: #35 Psycho\n", + "✅ Scraped: #36 The Lion King\n", + "✅ Scraped: #37 Grave of the Fireflies\n", + "✅ Scraped: #38 The Departed\n", + "✅ Scraped: #39 Whiplash\n", + "✅ Scraped: #40 Harakiri\n", + "✅ Scraped: #41 The Prestige\n", + "✅ Scraped: #42 American History X\n", + "✅ Scraped: #43 Léon: The Professional\n", + "✅ Scraped: #44 Spider-Man: Across the Spider-Verse\n", + "✅ Scraped: #45 Casablanca\n", + "✅ Scraped: #46 Cinema Paradiso\n", + "✅ Scraped: #47 The Usual Suspects\n", + "✅ Scraped: #48 The Intouchables\n", + "✅ Scraped: #49 Alien\n", + "✅ Scraped: #50 Modern Times\n", + "\n", + "Scraping completado. Se extrajeron datos de 50 películas.\n" + ] + } + ], + "source": [ + "# Selector para cada item (película) en la lista\n", + "movie_item_selector = \"li.ipc-metadata-list-summary-item\"\n", + "\n", + "# Pista: Usa el método 'find_elements' del driver para obtener una lista de todos los elementos que coincidan con 'movie_item_selector'.\n", + "movie_elements = # [...COMPLETA AQUÍ...]\n", + "\n", + "# Iteramos solo sobre las primeras 50 películas\n", + "for movie in movie_elements[:50]:\n", + " try:\n", + " # --- Rango y Título ---\n", + " # Pista: Primero, encuentra el elemento h3 con la clase 'ipc-title__text'. Luego, obtén su '.text'.\n", + " title_element = movie.find_element(By.CSS_SELECTOR, \"h3.ipc-title__text\")\n", + " full_title_text = # [...COMPLETA AQUÍ...]\n", + " rank, title = full_title_text.split('. ', 1)\n", + "\n", + " # --- Año --- \n", + " year = movie.find_element(By.CSS_SELECTOR, \"div.cli-title-metadata > span\").text\n", + " \n", + " # --- Calificación --- \n", + " rating_element = movie.find_element(By.CSS_SELECTOR, \"span.ipc-rating-star\")\n", + " rating = rating_element.text.split('\\n')[0]\n", + "\n", + " # --- URL de la película ---\n", + " # Pista: El enlace está en el atributo 'href' de la etiqueta . Usa '.get_attribute()'\n", + " url_element = movie.find_element(By.CSS_SELECTOR, \"a.ipc-title-link-wrapper\")\n", + " movie_url = # [...COMPLETA AQUÍ...]\n", + "\n", + " # Asegúrate de que los nombres de las variables coincidan con las que creaste arriba.\n", + " movies_data.append({\n", + " \"Rango\": # [...COMPLETA AQUÍ...],\n", + " \"Titulo\": # [...COMPLETA AQUÍ...],\n", + " \"Año\": year,\n", + " \"Calificacion_IMDb\": rating,\n", + " \"URL\": # [...COMPLETA AQUÍ...]\n", + " })\n", + " print(f\" Scraped: #{rank} {title}\")\n", + "\n", + " except Exception as e:\n", + " print(f\" Error extrayendo datos de una película. Error: {e}\")\n", + " continue\n", + "\n", + "print(f\"\\nScraping completado. Se extrajeron datos de {len(movies_data)} películas.\")" + ] + }, + { + "cell_type": "markdown", + "id": "e593f83e", + "metadata": {}, + "source": [ + "## 5. Crear el DataFrame y Guardar los Datos\n", + "\n", + "Una vez que tenemos nuestra lista de diccionarios, la convertimos en un DataFrame de pandas, que es una estructura tipo tabla ideal para el análisis y almacenamiento de datos. Finalmente, lo guardamos en un archivo CSV y cerramos el navegador para liberar los recursos del sistema." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "318ab0d9", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "🎉 Datos guardados exitosamente en 'imdb_top_50_peliculas.csv'\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
RangoTituloAñoCalificacion_IMDbURL
01The Shawshank Redemption19949.3https://www.imdb.com/title/tt0111161/?ref_=cht...
12The Godfather19729.2https://www.imdb.com/title/tt0068646/?ref_=cht...
23The Dark Knight20089.1https://www.imdb.com/title/tt0468569/?ref_=cht...
34The Godfather Part II19749.0https://www.imdb.com/title/tt0071562/?ref_=cht...
4512 Angry Men19579.0https://www.imdb.com/title/tt0050083/?ref_=cht...
\n", + "
" + ], + "text/plain": [ + " Rango Titulo Año Calificacion_IMDb \\\n", + "0 1 The Shawshank Redemption 1994 9.3 \n", + "1 2 The Godfather 1972 9.2 \n", + "2 3 The Dark Knight 2008 9.1 \n", + "3 4 The Godfather Part II 1974 9.0 \n", + "4 5 12 Angry Men 1957 9.0 \n", + "\n", + " URL \n", + "0 https://www.imdb.com/title/tt0111161/?ref_=cht... \n", + "1 https://www.imdb.com/title/tt0068646/?ref_=cht... \n", + "2 https://www.imdb.com/title/tt0468569/?ref_=cht... \n", + "3 https://www.imdb.com/title/tt0071562/?ref_=cht... \n", + "4 https://www.imdb.com/title/tt0050083/?ref_=cht... " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Navegador cerrado correctamente.\n" + ] + } + ], + "source": [ + "if movies_data:\n", + " # Pista: Llama a pd.DataFrame() y pásale la lista que contiene todos nuestros datos.\n", + " df = pd.DataFrame(# [...COMPLETA AQUÍ...])\n", + " # Pista: Usa el método '.to_csv()'. Dale un nombre de archivo, por ejemplo, \"imdb_top_50.csv\", y no te olvides de poner index=False.\n", + " # [...COMPLETA AQUÍ...]\n", + " \n", + " print(\"\\n Datos guardados exitosamente.\")\n", + " display(df.head())\n", + "else:\n", + " print(\"\\nNo se pudo extraer ningún dato de las películas.\")\n", + "\n", + "# Cerrar el navegador\n", + "# Pista: Hay un método en el objeto 'driver' para cerrar todas las ventanas y terminar la sesión.\n", + "# [...COMPLETA AQUÍ...]\n", + "\n", + "print(\"\\nNavegador cerrado correctamente. ¡Ejercicio terminado!\")\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "yelp_scraper", + "language": "python", + "name": "python3" + }, + "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.10.18" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Labs/Python_Notebooks/LAB2/Imbd_lab_students.ipynb b/Labs/Python_Notebooks/LAB2/Imbd_lab_students.ipynb index 9359e62a1..5288f9d04 100644 --- a/Labs/Python_Notebooks/LAB2/Imbd_lab_students.ipynb +++ b/Labs/Python_Notebooks/LAB2/Imbd_lab_students.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "id": "dc2d3ffc", "metadata": {}, "outputs": [], @@ -47,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "b2aaba9b", "metadata": {}, "outputs": [ @@ -69,8 +69,8 @@ "# Iniciar el WebDriver de Chrome\n", "# Pista: Crea una variable llamada 'driver' y asígnale la instancia de webdriver.Chrome(),\n", "# pasando nuestras 'chrome_options' como argumento.\n", - "driver = # [...COMPLETA AQUÍ...]\n", - "\n", + "driver = webdriver.Chrome(options=chrome_options)\n", + "# Salio bien\n", "print(\"WebDriver iniciado con éxito.\")" ] }, @@ -86,7 +86,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "a92ee23e", "metadata": {}, "outputs": [ @@ -95,16 +95,17 @@ "output_type": "stream", "text": [ "Esperando a que la lista de películas cargue...\n", - "Lista de películas encontrada. Comenzando el scraping.\n" + "Lista de películas encontrada. ¡A scrapear!\n" ] } ], "source": [ "# URL del Top 250 de IMDb\n", "url = \"https://www.imdb.com/chart/top/\"\n", + "driver = webdriver.Chrome(options=chrome_options)\n", "\n", "# Pista: El objeto 'driver' tiene un método para abrir una URL. ¿Cuál es?\n", - "# [...COMPLETA AQUÍ...]\n", + "driver.get(url)\n", "\n", "# Lista para guardar los datos de cada película\n", "movies_data = []\n", @@ -118,7 +119,7 @@ " # Completa la espera para que el script se detenga hasta que la lista de películas sea visible.\n", " # Pista: Usa EC.visibility_of_element_located() y pásale una tupla con el método de búsqueda (By) y el selector.\n", " WebDriverWait(driver, 10).until(\n", - " EC.visibility_of_element_located(( # [...COMPLETA AQUÍ EL MÉTODO By Y EL SELECTOR...] ))\n", + " EC.visibility_of_element_located(( By.CSS_SELECTOR,movie_list_selector ))\n", " )\n", " print(\"Lista de películas encontrada. ¡A scrapear!\")\n", "\n", @@ -142,9 +143,15 @@ "- Usamos bloques try-except para cada atributo. Si un dato no se encuentra en una película, el script registrará \"No disponible\" y continuará, en lugar de detenerse por un error." ] }, + { + "cell_type": "markdown", + "id": "bff313f6", + "metadata": {}, + "source": [] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "4d0d1eca", "metadata": {}, "outputs": [ @@ -152,56 +159,56 @@ "name": "stdout", "output_type": "stream", "text": [ - "✅ Scraped: #1 The Shawshank Redemption\n", - "✅ Scraped: #2 The Godfather\n", - "✅ Scraped: #3 The Dark Knight\n", - "✅ Scraped: #4 The Godfather Part II\n", - "✅ Scraped: #5 12 Angry Men\n", - "✅ Scraped: #6 The Lord of the Rings: The Return of the King\n", - "✅ Scraped: #7 Schindler's List\n", - "✅ Scraped: #8 Pulp Fiction\n", - "✅ Scraped: #9 The Lord of the Rings: The Fellowship of the Ring\n", - "✅ Scraped: #10 The Good, the Bad and the Ugly\n", - "✅ Scraped: #11 Forrest Gump\n", - "✅ Scraped: #12 The Lord of the Rings: The Two Towers\n", - "✅ Scraped: #13 Fight Club\n", - "✅ Scraped: #14 Inception\n", - "✅ Scraped: #15 Star Wars: Episode V - The Empire Strikes Back\n", - "✅ Scraped: #16 The Matrix\n", - "✅ Scraped: #17 Goodfellas\n", - "✅ Scraped: #18 Interstellar\n", - "✅ Scraped: #19 One Flew Over the Cuckoo's Nest\n", - "✅ Scraped: #20 Se7en\n", - "✅ Scraped: #21 It's a Wonderful Life\n", - "✅ Scraped: #22 The Silence of the Lambs\n", - "✅ Scraped: #23 Seven Samurai\n", - "✅ Scraped: #24 Saving Private Ryan\n", - "✅ Scraped: #25 The Green Mile\n", - "✅ Scraped: #26 City of God\n", - "✅ Scraped: #27 Life Is Beautiful\n", - "✅ Scraped: #28 Terminator 2: Judgment Day\n", - "✅ Scraped: #29 Star Wars: Episode IV - A New Hope\n", - "✅ Scraped: #30 Back to the Future\n", - "✅ Scraped: #31 Spirited Away\n", - "✅ Scraped: #32 The Pianist\n", - "✅ Scraped: #33 Gladiator\n", - "✅ Scraped: #34 Parasite\n", - "✅ Scraped: #35 Psycho\n", - "✅ Scraped: #36 The Lion King\n", - "✅ Scraped: #37 Grave of the Fireflies\n", - "✅ Scraped: #38 The Departed\n", - "✅ Scraped: #39 Whiplash\n", - "✅ Scraped: #40 Harakiri\n", - "✅ Scraped: #41 The Prestige\n", - "✅ Scraped: #42 American History X\n", - "✅ Scraped: #43 Léon: The Professional\n", - "✅ Scraped: #44 Spider-Man: Across the Spider-Verse\n", - "✅ Scraped: #45 Casablanca\n", - "✅ Scraped: #46 Cinema Paradiso\n", - "✅ Scraped: #47 The Usual Suspects\n", - "✅ Scraped: #48 The Intouchables\n", - "✅ Scraped: #49 Alien\n", - "✅ Scraped: #50 Modern Times\n", + " Scraped: #1 The Shawshank Redemption\n", + " Scraped: #2 The Godfather\n", + " Scraped: #3 The Dark Knight\n", + " Scraped: #4 The Godfather Part II\n", + " Scraped: #5 12 Angry Men\n", + " Scraped: #6 The Lord of the Rings: The Return of the King\n", + " Scraped: #7 Schindler's List\n", + " Scraped: #8 Pulp Fiction\n", + " Scraped: #9 The Lord of the Rings: The Fellowship of the Ring\n", + " Scraped: #10 The Good, the Bad and the Ugly\n", + " Scraped: #11 Forrest Gump\n", + " Scraped: #12 The Lord of the Rings: The Two Towers\n", + " Scraped: #13 Fight Club\n", + " Scraped: #14 Inception\n", + " Scraped: #15 Star Wars: Episode V - The Empire Strikes Back\n", + " Scraped: #16 The Matrix\n", + " Scraped: #17 Goodfellas\n", + " Scraped: #18 Interstellar\n", + " Scraped: #19 One Flew Over the Cuckoo's Nest\n", + " Scraped: #20 Se7en\n", + " Scraped: #21 It's a Wonderful Life\n", + " Scraped: #22 The Silence of the Lambs\n", + " Scraped: #23 Seven Samurai\n", + " Scraped: #24 Saving Private Ryan\n", + " Scraped: #25 The Green Mile\n", + " Scraped: #26 City of God\n", + " Scraped: #27 Life Is Beautiful\n", + " Scraped: #28 Terminator 2: Judgment Day\n", + " Scraped: #29 Star Wars: Episode IV - A New Hope\n", + " Scraped: #30 Back to the Future\n", + " Scraped: #31 Spirited Away\n", + " Scraped: #32 The Pianist\n", + " Scraped: #33 Gladiator\n", + " Scraped: #34 Parasite\n", + " Scraped: #35 Psycho\n", + " Scraped: #36 The Lion King\n", + " Scraped: #37 Grave of the Fireflies\n", + " Scraped: #38 The Departed\n", + " Scraped: #39 Whiplash\n", + " Scraped: #40 Harakiri\n", + " Scraped: #41 The Prestige\n", + " Scraped: #42 American History X\n", + " Scraped: #43 Léon: The Professional\n", + " Scraped: #44 Spider-Man: Across the Spider-Verse\n", + " Scraped: #45 Casablanca\n", + " Scraped: #46 Cinema Paradiso\n", + " Scraped: #47 The Usual Suspects\n", + " Scraped: #48 The Intouchables\n", + " Scraped: #49 Alien\n", + " Scraped: #50 Modern Times\n", "\n", "Scraping completado. Se extrajeron datos de 50 películas.\n" ] @@ -212,7 +219,8 @@ "movie_item_selector = \"li.ipc-metadata-list-summary-item\"\n", "\n", "# Pista: Usa el método 'find_elements' del driver para obtener una lista de todos los elementos que coincidan con 'movie_item_selector'.\n", - "movie_elements = # [...COMPLETA AQUÍ...]\n", + "movie_elements = driver.find_elements(By.CSS_SELECTOR, movie_item_selector)\n", + "\n", "\n", "# Iteramos solo sobre las primeras 50 películas\n", "for movie in movie_elements[:50]:\n", @@ -220,7 +228,7 @@ " # --- Rango y Título ---\n", " # Pista: Primero, encuentra el elemento h3 con la clase 'ipc-title__text'. Luego, obtén su '.text'.\n", " title_element = movie.find_element(By.CSS_SELECTOR, \"h3.ipc-title__text\")\n", - " full_title_text = # [...COMPLETA AQUÍ...]\n", + " full_title_text = title_element.text\n", " rank, title = full_title_text.split('. ', 1)\n", "\n", " # --- Año --- \n", @@ -233,15 +241,15 @@ " # --- URL de la película ---\n", " # Pista: El enlace está en el atributo 'href' de la etiqueta
. Usa '.get_attribute()'\n", " url_element = movie.find_element(By.CSS_SELECTOR, \"a.ipc-title-link-wrapper\")\n", - " movie_url = # [...COMPLETA AQUÍ...]\n", + " movie_url = url_element.get_attribute(\"href\")\n", "\n", " # Asegúrate de que los nombres de las variables coincidan con las que creaste arriba.\n", " movies_data.append({\n", - " \"Rango\": # [...COMPLETA AQUÍ...],\n", - " \"Titulo\": # [...COMPLETA AQUÍ...],\n", + " \"Rango\": rank,\n", + " \"Titulo\": title,\n", " \"Año\": year,\n", " \"Calificacion_IMDb\": rating,\n", - " \"URL\": # [...COMPLETA AQUÍ...]\n", + " \"URL\": movie_url\n", " })\n", " print(f\" Scraped: #{rank} {title}\")\n", "\n", @@ -252,6 +260,12 @@ "print(f\"\\nScraping completado. Se extrajeron datos de {len(movies_data)} películas.\")" ] }, + { + "cell_type": "markdown", + "id": "a5e8a865", + "metadata": {}, + "source": [] + }, { "cell_type": "markdown", "id": "e593f83e", @@ -264,7 +278,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "318ab0d9", "metadata": {}, "outputs": [ @@ -273,7 +287,7 @@ "output_type": "stream", "text": [ "\n", - "🎉 Datos guardados exitosamente en 'imdb_top_50_peliculas.csv'\n" + " Datos guardados exitosamente.\n" ] }, { @@ -373,16 +387,16 @@ "output_type": "stream", "text": [ "\n", - "Navegador cerrado correctamente.\n" + "Navegador cerrado correctamente. ¡Ejercicio terminado!\n" ] } ], "source": [ "if movies_data:\n", " # Pista: Llama a pd.DataFrame() y pásale la lista que contiene todos nuestros datos.\n", - " df = pd.DataFrame(# [...COMPLETA AQUÍ...])\n", + " df = pd.DataFrame(movies_data)\n", " # Pista: Usa el método '.to_csv()'. Dale un nombre de archivo, por ejemplo, \"imdb_top_50.csv\", y no te olvides de poner index=False.\n", - " # [...COMPLETA AQUÍ...]\n", + " df.to_csv(\"imdb_top_50.csv\", index=False)\n", " \n", " print(\"\\n Datos guardados exitosamente.\")\n", " display(df.head())\n", @@ -391,7 +405,7 @@ "\n", "# Cerrar el navegador\n", "# Pista: Hay un método en el objeto 'driver' para cerrar todas las ventanas y terminar la sesión.\n", - "# [...COMPLETA AQUÍ...]\n", + "driver.quit()\n", "\n", "print(\"\\nNavegador cerrado correctamente. ¡Ejercicio terminado!\")\n" ] @@ -399,7 +413,7 @@ ], "metadata": { "kernelspec": { - "display_name": "yelp_scraper", + "display_name": "lab2", "language": "python", "name": "python3" }, diff --git a/Labs/Python_Notebooks/LAB2/Prueba2.ipynb b/Labs/Python_Notebooks/LAB2/Prueba2.ipynb new file mode 100644 index 000000000..e69de29bb diff --git a/Labs/Python_Notebooks/LAB2/imdb_top_50.csv b/Labs/Python_Notebooks/LAB2/imdb_top_50.csv new file mode 100644 index 000000000..c7ae45ce4 --- /dev/null +++ b/Labs/Python_Notebooks/LAB2/imdb_top_50.csv @@ -0,0 +1,51 @@ +Rango,Titulo,Año,Calificacion_IMDb,URL +1,The Shawshank Redemption,1994,9.3,https://www.imdb.com/title/tt0111161/?ref_=chttp_t_1 +2,The Godfather,1972,9.2,https://www.imdb.com/title/tt0068646/?ref_=chttp_t_2 +3,The Dark Knight,2008,9.1,https://www.imdb.com/title/tt0468569/?ref_=chttp_t_3 +4,The Godfather Part II,1974,9.0,https://www.imdb.com/title/tt0071562/?ref_=chttp_t_4 +5,12 Angry Men,1957,9.0,https://www.imdb.com/title/tt0050083/?ref_=chttp_t_5 +6,The Lord of the Rings: The Return of the King,2003,9.0,https://www.imdb.com/title/tt0167260/?ref_=chttp_t_6 +7,Schindler's List,1993,9.0,https://www.imdb.com/title/tt0108052/?ref_=chttp_t_7 +8,Pulp Fiction,1994,8.8,https://www.imdb.com/title/tt0110912/?ref_=chttp_t_8 +9,The Lord of the Rings: The Fellowship of the Ring,2001,8.9,https://www.imdb.com/title/tt0120737/?ref_=chttp_t_9 +10,"The Good, the Bad and the Ugly",1966,8.8,https://www.imdb.com/title/tt0060196/?ref_=chttp_t_10 +11,Forrest Gump,1994,8.8,https://www.imdb.com/title/tt0109830/?ref_=chttp_t_11 +12,The Lord of the Rings: The Two Towers,2002,8.8,https://www.imdb.com/title/tt0167261/?ref_=chttp_t_12 +13,Fight Club,1999,8.8,https://www.imdb.com/title/tt0137523/?ref_=chttp_t_13 +14,Inception,2010,8.8,https://www.imdb.com/title/tt1375666/?ref_=chttp_t_14 +15,Star Wars: Episode V - The Empire Strikes Back,1980,8.7,https://www.imdb.com/title/tt0080684/?ref_=chttp_t_15 +16,The Matrix,1999,8.7,https://www.imdb.com/title/tt0133093/?ref_=chttp_t_16 +17,Goodfellas,1990,8.7,https://www.imdb.com/title/tt0099685/?ref_=chttp_t_17 +18,Interstellar,2014,8.7,https://www.imdb.com/title/tt0816692/?ref_=chttp_t_18 +19,One Flew Over the Cuckoo's Nest,1975,8.7,https://www.imdb.com/title/tt0073486/?ref_=chttp_t_19 +20,Se7en,1995,8.6,https://www.imdb.com/title/tt0114369/?ref_=chttp_t_20 +21,It's a Wonderful Life,1946,8.6,https://www.imdb.com/title/tt0038650/?ref_=chttp_t_21 +22,The Silence of the Lambs,1991,8.6,https://www.imdb.com/title/tt0102926/?ref_=chttp_t_22 +23,Seven Samurai,1954,8.6,https://www.imdb.com/title/tt0047478/?ref_=chttp_t_23 +24,Saving Private Ryan,1998,8.6,https://www.imdb.com/title/tt0120815/?ref_=chttp_t_24 +25,The Green Mile,1999,8.6,https://www.imdb.com/title/tt0120689/?ref_=chttp_t_25 +26,City of God,2002,8.6,https://www.imdb.com/title/tt0317248/?ref_=chttp_t_26 +27,Life Is Beautiful,1997,8.6,https://www.imdb.com/title/tt0118799/?ref_=chttp_t_27 +28,Terminator 2: Judgment Day,1991,8.6,https://www.imdb.com/title/tt0103064/?ref_=chttp_t_28 +29,Star Wars: Episode IV - A New Hope,1977,8.6,https://www.imdb.com/title/tt0076759/?ref_=chttp_t_29 +30,Back to the Future,1985,8.5,https://www.imdb.com/title/tt0088763/?ref_=chttp_t_30 +31,Spirited Away,2001,8.6,https://www.imdb.com/title/tt0245429/?ref_=chttp_t_31 +32,The Pianist,2002,8.5,https://www.imdb.com/title/tt0253474/?ref_=chttp_t_32 +33,Gladiator,2000,8.5,https://www.imdb.com/title/tt0172495/?ref_=chttp_t_33 +34,Parasite,2019,8.5,https://www.imdb.com/title/tt6751668/?ref_=chttp_t_34 +35,Psycho,1960,8.5,https://www.imdb.com/title/tt0054215/?ref_=chttp_t_35 +36,The Lion King,1994,8.5,https://www.imdb.com/title/tt0110357/?ref_=chttp_t_36 +37,Grave of the Fireflies,1988,8.5,https://www.imdb.com/title/tt0095327/?ref_=chttp_t_37 +38,The Departed,2006,8.5,https://www.imdb.com/title/tt0407887/?ref_=chttp_t_38 +39,Whiplash,2014,8.5,https://www.imdb.com/title/tt2582802/?ref_=chttp_t_39 +40,Harakiri,1962,8.6,https://www.imdb.com/title/tt0056058/?ref_=chttp_t_40 +41,The Prestige,2006,8.5,https://www.imdb.com/title/tt0482571/?ref_=chttp_t_41 +42,American History X,1998,8.5,https://www.imdb.com/title/tt0120586/?ref_=chttp_t_42 +43,Léon: The Professional,1994,8.5,https://www.imdb.com/title/tt0110413/?ref_=chttp_t_43 +44,Spider-Man: Across the Spider-Verse,2023,8.5,https://www.imdb.com/title/tt9362722/?ref_=chttp_t_44 +45,Casablanca,1942,8.5,https://www.imdb.com/title/tt0034583/?ref_=chttp_t_45 +46,Cinema Paradiso,1988,8.5,https://www.imdb.com/title/tt0095765/?ref_=chttp_t_46 +47,The Usual Suspects,1995,8.5,https://www.imdb.com/title/tt0114814/?ref_=chttp_t_47 +48,The Intouchables,2011,8.5,https://www.imdb.com/title/tt1675434/?ref_=chttp_t_48 +49,Alien,1979,8.5,https://www.imdb.com/title/tt0078748/?ref_=chttp_t_49 +50,Modern Times,1936,8.5,https://www.imdb.com/title/tt0027977/?ref_=chttp_t_50 diff --git a/Labs/Python_Notebooks/LAB2/requirements.txt b/Labs/Python_Notebooks/LAB2/requirements.txt new file mode 100644 index 000000000..00ddf07cd --- /dev/null +++ b/Labs/Python_Notebooks/LAB2/requirements.txt @@ -0,0 +1,5 @@ +selenium==4.23.1 +webdriver-manager==4.0.1 +pandas==2.2.2 +jupyter==1.0.0 +notebook==7.2.2 \ No newline at end of file diff --git a/Lectures/Lecture_2/Images/resultados_presidenciales.png b/Lectures/Lecture_2/Images/resultados_presidenciales.png index 45e2900c0..1dbc10f35 100644 Binary files a/Lectures/Lecture_2/Images/resultados_presidenciales.png and b/Lectures/Lecture_2/Images/resultados_presidenciales.png differ diff --git a/Lectures/Lecture_2/lecture_7.ipynb b/Lectures/Lecture_2/lecture_7.ipynb index c2b6f605d..6cfa33395 100644 --- a/Lectures/Lecture_2/lecture_7.ipynb +++ b/Lectures/Lecture_2/lecture_7.ipynb @@ -71,9 +71,134 @@ "cell_type": "code", "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: beautifulsoup4==4.12 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from -r requirements.txt (line 1)) (4.12.0)\n", + "Requirement already satisfied: html5lib==1.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from -r requirements.txt (line 2)) (1.1)\n", + "Requirement already satisfied: ipykernel==6.29 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from -r requirements.txt (line 3)) (6.29.0)\n", + "Requirement already satisfied: ipywidgets==8.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from -r requirements.txt (line 4)) (8.1.0)\n", + "Requirement already satisfied: jupyter==1.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from -r requirements.txt (line 5)) (1.1.0)\n", + "Requirement already satisfied: lxml==5.3 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from -r requirements.txt (line 6)) (5.3.0)\n", + "Requirement already satisfied: openpyxl==3.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from -r requirements.txt (line 7)) (3.1.0)\n", + "Requirement already satisfied: pandas==2.2 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from -r requirements.txt (line 8)) (2.2.0)\n", + "Requirement already satisfied: selenium==4.28 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from -r requirements.txt (line 9)) (4.28.0)\n", + "Requirement already satisfied: tqdm==4.67 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from -r requirements.txt (line 10)) (4.67.0)\n", + "Requirement already satisfied: soupsieve>1.2 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from beautifulsoup4==4.12->-r requirements.txt (line 1)) (2.5)\n", + "Requirement already satisfied: six>=1.9 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from html5lib==1.1->-r requirements.txt (line 2)) (1.17.0)\n", + "Requirement already satisfied: webencodings in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from html5lib==1.1->-r requirements.txt (line 2)) (0.5.1)\n", + "Requirement already satisfied: comm>=0.1.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (0.2.1)\n", + "Requirement already satisfied: debugpy>=1.6.5 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (1.8.11)\n", + "Requirement already satisfied: ipython>=7.23.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (8.30.0)\n", + "Requirement already satisfied: jupyter-client>=6.1.12 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (8.6.3)\n", + "Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (5.8.1)\n", + "Requirement already satisfied: matplotlib-inline>=0.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (0.1.6)\n", + "Requirement already satisfied: nest-asyncio in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (1.6.0)\n", + "Requirement already satisfied: packaging in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (25.0)\n", + "Requirement already satisfied: psutil in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (5.9.0)\n", + "Requirement already satisfied: pyzmq>=24 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (26.2.0)\n", + "Requirement already satisfied: tornado>=6.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (6.5.1)\n", + "Requirement already satisfied: traitlets>=5.4.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipykernel==6.29->-r requirements.txt (line 3)) (5.14.3)\n", + "Requirement already satisfied: widgetsnbextension~=4.0.7 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipywidgets==8.1->-r requirements.txt (line 4)) (4.0.14)\n", + "Requirement already satisfied: jupyterlab-widgets~=3.0.7 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipywidgets==8.1->-r requirements.txt (line 4)) (3.0.15)\n", + "Requirement already satisfied: notebook in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter==1.1->-r requirements.txt (line 5)) (7.4.4)\n", + "Requirement already satisfied: jupyter-console in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter==1.1->-r requirements.txt (line 5)) (6.6.3)\n", + "Requirement already satisfied: nbconvert in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter==1.1->-r requirements.txt (line 5)) (7.16.6)\n", + "Requirement already satisfied: jupyterlab in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter==1.1->-r requirements.txt (line 5)) (4.4.4)\n", + "Requirement already satisfied: et-xmlfile in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from openpyxl==3.1->-r requirements.txt (line 7)) (2.0.0)\n", + "Requirement already satisfied: numpy<2,>=1.22.4 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from pandas==2.2->-r requirements.txt (line 8)) (1.26.4)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from pandas==2.2->-r requirements.txt (line 8)) (2.9.0.post0)\n", + "Requirement already satisfied: pytz>=2020.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from pandas==2.2->-r requirements.txt (line 8)) (2025.2)\n", + "Requirement already satisfied: tzdata>=2022.7 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from pandas==2.2->-r requirements.txt (line 8)) (2025.2)\n", + "Requirement already satisfied: urllib3<3,>=1.26 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from urllib3[socks]<3,>=1.26->selenium==4.28->-r requirements.txt (line 9)) (2.5.0)\n", + "Requirement already satisfied: trio~=0.17 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from selenium==4.28->-r requirements.txt (line 9)) (0.30.0)\n", + "Requirement already satisfied: trio-websocket~=0.9 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from selenium==4.28->-r requirements.txt (line 9)) (0.12.2)\n", + "Requirement already satisfied: certifi>=2021.10.8 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from selenium==4.28->-r requirements.txt (line 9)) (2025.8.3)\n", + "Requirement already satisfied: typing_extensions~=4.9 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from selenium==4.28->-r requirements.txt (line 9)) (4.12.2)\n", + "Requirement already satisfied: websocket-client~=1.8 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from selenium==4.28->-r requirements.txt (line 9)) (1.8.0)\n", + "Requirement already satisfied: colorama in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from tqdm==4.67->-r requirements.txt (line 10)) (0.4.6)\n", + "Requirement already satisfied: attrs>=23.2.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from trio~=0.17->selenium==4.28->-r requirements.txt (line 9)) (24.3.0)\n", + "Requirement already satisfied: sortedcontainers in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from trio~=0.17->selenium==4.28->-r requirements.txt (line 9)) (2.4.0)\n", + "Requirement already satisfied: idna in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from trio~=0.17->selenium==4.28->-r requirements.txt (line 9)) (3.7)\n", + "Requirement already satisfied: outcome in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from trio~=0.17->selenium==4.28->-r requirements.txt (line 9)) (1.3.0.post0)\n", + "Requirement already satisfied: sniffio>=1.3.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from trio~=0.17->selenium==4.28->-r requirements.txt (line 9)) (1.3.0)\n", + "Requirement already satisfied: cffi>=1.14 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from trio~=0.17->selenium==4.28->-r requirements.txt (line 9)) (1.17.1)\n", + "Requirement already satisfied: exceptiongroup in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from trio~=0.17->selenium==4.28->-r requirements.txt (line 9)) (1.2.0)\n", + "Requirement already satisfied: wsproto>=0.14 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from trio-websocket~=0.9->selenium==4.28->-r requirements.txt (line 9)) (1.2.0)\n", + "Requirement already satisfied: pysocks!=1.5.7,<2.0,>=1.5.6 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from urllib3[socks]<3,>=1.26->selenium==4.28->-r requirements.txt (line 9)) (1.7.1)\n", + "Requirement already satisfied: pycparser in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from cffi>=1.14->trio~=0.17->selenium==4.28->-r requirements.txt (line 9)) (2.21)\n", + "Requirement already satisfied: decorator in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipython>=7.23.1->ipykernel==6.29->-r requirements.txt (line 3)) (5.1.1)\n", + "Requirement already satisfied: jedi>=0.16 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipython>=7.23.1->ipykernel==6.29->-r requirements.txt (line 3)) (0.19.2)\n", + "Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipython>=7.23.1->ipykernel==6.29->-r requirements.txt (line 3)) (3.0.43)\n", + "Requirement already satisfied: pygments>=2.4.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipython>=7.23.1->ipykernel==6.29->-r requirements.txt (line 3)) (2.19.1)\n", + "Requirement already satisfied: stack-data in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from ipython>=7.23.1->ipykernel==6.29->-r requirements.txt (line 3)) (0.2.0)\n", + "Requirement already satisfied: wcwidth in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=7.23.1->ipykernel==6.29->-r requirements.txt (line 3)) (0.2.13)\n", + "Requirement already satisfied: parso<0.9.0,>=0.8.4 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jedi>=0.16->ipython>=7.23.1->ipykernel==6.29->-r requirements.txt (line 3)) (0.8.4)\n", + "Requirement already satisfied: platformdirs>=2.5 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-core!=5.0.*,>=4.12->ipykernel==6.29->-r requirements.txt (line 3)) (4.3.7)\n", + "Requirement already satisfied: pywin32>=300 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-core!=5.0.*,>=4.12->ipykernel==6.29->-r requirements.txt (line 3)) (311)\n", + "Requirement already satisfied: h11<1,>=0.9.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium==4.28->-r requirements.txt (line 9)) (0.16.0)\n", + "Requirement already satisfied: async-lru>=1.0.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2.0.4)\n", + "Requirement already satisfied: httpx>=0.25.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.28.1)\n", + "Requirement already satisfied: jinja2>=3.0.3 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (3.1.6)\n", + "Requirement already satisfied: jupyter-lsp>=2.0.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2.2.5)\n", + "Requirement already satisfied: jupyter-server<3,>=2.4.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2.16.0)\n", + "Requirement already satisfied: jupyterlab-server<3,>=2.27.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2.27.3)\n", + "Requirement already satisfied: notebook-shim>=0.2 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.2.4)\n", + "Requirement already satisfied: setuptools>=41.1.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (78.1.1)\n", + "Requirement already satisfied: tomli>=1.2.2 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2.2.1)\n", + "Requirement already satisfied: anyio>=3.1.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (4.7.0)\n", + "Requirement already satisfied: argon2-cffi>=21.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (21.3.0)\n", + "Requirement already satisfied: jupyter-events>=0.11.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.12.0)\n", + "Requirement already satisfied: jupyter-server-terminals>=0.4.4 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.5.3)\n", + "Requirement already satisfied: nbformat>=5.3.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (5.10.4)\n", + "Requirement already satisfied: overrides>=5.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (7.4.0)\n", + "Requirement already satisfied: prometheus-client>=0.9 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.21.1)\n", + "Requirement already satisfied: pywinpty>=2.0.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2.0.15)\n", + "Requirement already satisfied: send2trash>=1.8.2 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (1.8.2)\n", + "Requirement already satisfied: terminado>=0.8.3 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.17.1)\n", + "Requirement already satisfied: babel>=2.10 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2.16.0)\n", + "Requirement already satisfied: json5>=0.9.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.9.25)\n", + "Requirement already satisfied: jsonschema>=4.18.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (4.25.0)\n", + "Requirement already satisfied: requests>=2.31 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2.32.4)\n", + "Requirement already satisfied: argon2-cffi-bindings in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from argon2-cffi>=21.1->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (21.2.0)\n", + "Requirement already satisfied: httpcore==1.* in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from httpx>=0.25.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (1.0.9)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jinja2>=3.0.3->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (3.0.2)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2023.7.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.30.2)\n", + "Requirement already satisfied: rpds-py>=0.7.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.22.3)\n", + "Requirement already satisfied: python-json-logger>=2.0.4 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (3.2.1)\n", + "Requirement already satisfied: pyyaml>=5.3 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (6.0.2)\n", + "Requirement already satisfied: rfc3339-validator in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.1.4)\n", + "Requirement already satisfied: rfc3986-validator>=0.1.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (0.1.1)\n", + "Requirement already satisfied: fqdn in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (1.5.1)\n", + "Requirement already satisfied: isoduration in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (20.11.0)\n", + "Requirement already satisfied: jsonpointer>1.13 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (3.0.0)\n", + "Requirement already satisfied: rfc3987-syntax>=1.1.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (1.1.0)\n", + "Requirement already satisfied: uri-template in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (1.3.0)\n", + "Requirement already satisfied: webcolors>=24.6.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (24.11.1)\n", + "Requirement already satisfied: bleach!=5.0.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from bleach[css]!=5.0.0->nbconvert->jupyter==1.1->-r requirements.txt (line 5)) (6.2.0)\n", + "Requirement already satisfied: defusedxml in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from nbconvert->jupyter==1.1->-r requirements.txt (line 5)) (0.7.1)\n", + "Requirement already satisfied: jupyterlab-pygments in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from nbconvert->jupyter==1.1->-r requirements.txt (line 5)) (0.3.0)\n", + "Requirement already satisfied: mistune<4,>=2.0.3 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from nbconvert->jupyter==1.1->-r requirements.txt (line 5)) (3.1.2)\n", + "Requirement already satisfied: nbclient>=0.5.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from nbconvert->jupyter==1.1->-r requirements.txt (line 5)) (0.10.2)\n", + "Requirement already satisfied: pandocfilters>=1.4.1 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from nbconvert->jupyter==1.1->-r requirements.txt (line 5)) (1.5.0)\n", + "Requirement already satisfied: tinycss2<1.5,>=1.1.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from bleach[css]!=5.0.0->nbconvert->jupyter==1.1->-r requirements.txt (line 5)) (1.4.0)\n", + "Requirement already satisfied: fastjsonschema>=2.15 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from nbformat>=5.3.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2.20.0)\n", + "Requirement already satisfied: charset_normalizer<4,>=2 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from requests>=2.31->jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (3.3.2)\n", + "Requirement already satisfied: lark>=1.2.2 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from rfc3987-syntax>=1.1.0->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (1.2.2)\n", + "Requirement already satisfied: arrow>=0.15.0 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from isoduration->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (1.3.0)\n", + "Requirement already satisfied: types-python-dateutil>=2.8.10 in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from arrow>=0.15.0->isoduration->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter==1.1->-r requirements.txt (line 5)) (2.9.0.20250809)\n", + "Requirement already satisfied: executing in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from stack-data->ipython>=7.23.1->ipykernel==6.29->-r requirements.txt (line 3)) (0.8.3)\n", + "Requirement already satisfied: asttokens in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from stack-data->ipython>=7.23.1->ipykernel==6.29->-r requirements.txt (line 3)) (3.0.0)\n", + "Requirement already satisfied: pure-eval in c:\\users\\pc\\.conda\\envs\\py310\\lib\\site-packages (from stack-data->ipython>=7.23.1->ipykernel==6.29->-r requirements.txt (line 3)) (0.2.2)\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], "source": [ - "# !pip install -r requirements.txt" + "pip install -r requirements.txt" ] }, { @@ -85,7 +210,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -110,7 +235,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -122,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -154,7 +279,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -3564,7 +3689,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.10.18" }, "toc": { "base_numbering": 1,