Commit c65b47d4 authored by geobumac's avatar geobumac

Merge branch 'master' into gaspar

# Conflicts:
#	05-NumPy&Pandas.ipynb
#	07-LinearAlgebra&Learning.ipynb
parents a66352b7 834b7496
...@@ -612,9 +612,9 @@ ...@@ -612,9 +612,9 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[2., 2., 9., 4.],\n", "array([[2., 9., 8., 6.],\n",
" [6., 6., 3., 6.],\n", " [8., 4., 2., 9.],\n",
" [7., 9., 9., 8.]])" " [1., 1., 4., 5.]])"
] ]
}, },
"execution_count": 26, "execution_count": 26,
...@@ -655,12 +655,12 @@ ...@@ -655,12 +655,12 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[2., 2.],\n", "array([[2., 9.],\n",
" [9., 4.],\n", " [8., 6.],\n",
" [6., 6.],\n", " [8., 4.],\n",
" [3., 6.],\n", " [2., 9.],\n",
" [7., 9.],\n", " [1., 1.],\n",
" [9., 8.]])" " [4., 5.]])"
] ]
}, },
"execution_count": 28, "execution_count": 28,
...@@ -680,10 +680,10 @@ ...@@ -680,10 +680,10 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[2., 6., 7.],\n", "array([[2., 8., 1.],\n",
" [2., 6., 9.],\n", " [9., 4., 1.],\n",
" [9., 3., 9.],\n", " [8., 2., 4.],\n",
" [4., 6., 8.]])" " [6., 9., 5.]])"
] ]
}, },
"execution_count": 29, "execution_count": 29,
...@@ -746,9 +746,9 @@ ...@@ -746,9 +746,9 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[2., 2., 9., 4.],\n", "array([[2., 9., 8., 6.],\n",
" [6., 6., 3., 6.],\n", " [8., 4., 2., 9.],\n",
" [7., 9., 9., 8.]])" " [1., 1., 4., 5.]])"
] ]
}, },
"execution_count": 32, "execution_count": 32,
...@@ -953,11 +953,11 @@ ...@@ -953,11 +953,11 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"a -0.192610\n", "a 1.085164\n",
"b 0.957230\n", "b 0.684054\n",
"c -0.917233\n", "c -3.137046\n",
"d 1.156523\n", "d -0.780916\n",
"e -0.539532\n", "e 0.497413\n",
"dtype: float64" "dtype: float64"
] ]
}, },
...@@ -979,11 +979,11 @@ ...@@ -979,11 +979,11 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"0 -0.856313\n", "0 -0.165303\n",
"1 -0.342923\n", "1 0.089697\n",
"2 -1.398583\n", "2 -1.680879\n",
"3 0.170869\n", "3 -0.160729\n",
"4 1.049196\n", "4 0.235082\n",
"dtype: float64" "dtype: float64"
] ]
}, },
...@@ -1057,7 +1057,7 @@ ...@@ -1057,7 +1057,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"-0.19261011238315226" "1.0851635954341003"
] ]
}, },
"execution_count": 40, "execution_count": 40,
...@@ -1077,9 +1077,9 @@ ...@@ -1077,9 +1077,9 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"a -0.192610\n", "a 1.085164\n",
"b 0.957230\n", "b 0.684054\n",
"c -0.917233\n", "c -3.137046\n",
"dtype: float64" "dtype: float64"
] ]
}, },
...@@ -1100,8 +1100,9 @@ ...@@ -1100,8 +1100,9 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"b 0.957230\n", "a 1.085164\n",
"d 1.156523\n", "b 0.684054\n",
"e 0.497413\n",
"dtype: float64" "dtype: float64"
] ]
}, },
...@@ -1122,11 +1123,11 @@ ...@@ -1122,11 +1123,11 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"a -0.385220\n", "a 2.170327\n",
"b 1.914460\n", "b 1.368108\n",
"c -1.834466\n", "c -6.274092\n",
"d 2.313046\n", "d -1.561832\n",
"e -1.079065\n", "e 0.994826\n",
"dtype: float64" "dtype: float64"
] ]
}, },
...@@ -1147,10 +1148,10 @@ ...@@ -1147,10 +1148,10 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"a False\n", "a True\n",
"b True\n", "b True\n",
"c False\n", "c False\n",
"d True\n", "d False\n",
"e False\n", "e False\n",
"dtype: bool" "dtype: bool"
] ]
...@@ -1172,7 +1173,7 @@ ...@@ -1172,7 +1173,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"-0.19261011238315226" "1.0851635954341003"
] ]
}, },
"execution_count": 45, "execution_count": 45,
...@@ -1320,7 +1321,7 @@ ...@@ -1320,7 +1321,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"### 5.3.2 DataFrame\n", "### 5.3.2 DataFrame\n",
"DataFrame es un estructura bidimensiona etiquetada con columnas que pueden ser de diferentes tipos, es el objeto mas usado en pandas, se puede pensar en ella como un diccionario de **Series**. **DataFrame** acepta diferentes tipos de entradas como:\n", "DataFrame es un estructura bidimensional etiquetada con columnas que pueden ser de diferentes tipos, es el objeto mas usado en pandas, se puede pensar en ella como un diccionario de **Series**. **DataFrame** acepta diferentes tipos de entradas como:\n",
"* Diccionarios de arreglos unidimensionales, listas dicionarios o series. \n", "* Diccionarios de arreglos unidimensionales, listas dicionarios o series. \n",
"* 2-D numpy.ndarray\n", "* 2-D numpy.ndarray\n",
"* Series\n", "* Series\n",
...@@ -1344,7 +1345,7 @@ ...@@ -1344,7 +1345,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"d = {'one': pd.Series([1., 2., 3.], index=['a', 'b', 'c']),\n", "d = {'one': pd.Series([1., 2., 3.], index=['a', 'b', 'c']),\n",
" 'two': pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])}" " 'two': pd.Series([1., 2., 3., 4.], index=['a', 'x', 'c', 'd'])}"
] ]
}, },
{ {
...@@ -1395,7 +1396,7 @@ ...@@ -1395,7 +1396,7 @@
" <tr>\n", " <tr>\n",
" <th>b</th>\n", " <th>b</th>\n",
" <td>2.0</td>\n", " <td>2.0</td>\n",
" <td>2.0</td>\n", " <td>NaN</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>c</th>\n", " <th>c</th>\n",
...@@ -1407,6 +1408,11 @@ ...@@ -1407,6 +1408,11 @@
" <td>NaN</td>\n", " <td>NaN</td>\n",
" <td>4.0</td>\n", " <td>4.0</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
"</div>" "</div>"
...@@ -1414,9 +1420,10 @@ ...@@ -1414,9 +1420,10 @@
"text/plain": [ "text/plain": [
" one two\n", " one two\n",
"a 1.0 1.0\n", "a 1.0 1.0\n",
"b 2.0 2.0\n", "b 2.0 NaN\n",
"c 3.0 3.0\n", "c 3.0 3.0\n",
"d NaN 4.0" "d NaN 4.0\n",
"x NaN 2.0"
] ]
}, },
"execution_count": 24, "execution_count": 24,
...@@ -1447,6 +1454,7 @@ ...@@ -1447,6 +1454,7 @@
"b 2.0\n", "b 2.0\n",
"c 3.0\n", "c 3.0\n",
"d NaN\n", "d NaN\n",
"x NaN\n",
"Name: one, dtype: float64" "Name: one, dtype: float64"
] ]
}, },
...@@ -1502,8 +1510,8 @@ ...@@ -1502,8 +1510,8 @@
" <tr>\n", " <tr>\n",
" <th>b</th>\n", " <th>b</th>\n",
" <td>2.0</td>\n", " <td>2.0</td>\n",
" <td>2.0</td>\n", " <td>NaN</td>\n",
" <td>4.0</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
...@@ -1520,6 +1528,13 @@ ...@@ -1520,6 +1528,13 @@
" <td>NaN</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
"</div>" "</div>"
...@@ -1527,9 +1542,10 @@ ...@@ -1527,9 +1542,10 @@
"text/plain": [ "text/plain": [
" one two three flag\n", " one two three flag\n",
"a 1.0 1.0 1.0 False\n", "a 1.0 1.0 1.0 False\n",
"b 2.0 2.0 4.0 False\n", "b 2.0 NaN NaN False\n",
"c 3.0 3.0 9.0 True\n", "c 3.0 3.0 9.0 True\n",
"d NaN 4.0 NaN False" "d NaN 4.0 NaN False\n",
"x NaN 2.0 NaN False"
] ]
}, },
"execution_count": 26, "execution_count": 26,
...@@ -1612,6 +1628,11 @@ ...@@ -1612,6 +1628,11 @@
" <td>NaN</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
"</div>" "</div>"
...@@ -1621,7 +1642,8 @@ ...@@ -1621,7 +1642,8 @@
"a 1.0 False\n", "a 1.0 False\n",
"b 2.0 False\n", "b 2.0 False\n",
"c 3.0 True\n", "c 3.0 True\n",
"d NaN False" "d NaN False\n",
"x NaN False"
] ]
}, },
"execution_count": 59, "execution_count": 59,
...@@ -1660,7 +1682,7 @@ ...@@ -1660,7 +1682,7 @@
" <tr style=\"text-align: right;\">\n", " <tr style=\"text-align: right;\">\n",
" <th></th>\n", " <th></th>\n",
" <th>one</th>\n", " <th>one</th>\n",
" <th>three</th>\n", " <th>two</th>\n",
" <th>flag</th>\n", " <th>flag</th>\n",
" </tr>\n", " </tr>\n",
" </thead>\n", " </thead>\n",
...@@ -1674,7 +1696,7 @@ ...@@ -1674,7 +1696,7 @@
" <tr>\n", " <tr>\n",
" <th>b</th>\n", " <th>b</th>\n",
" <td>2.0</td>\n", " <td>2.0</td>\n",
" <td>4.0</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
...@@ -1689,16 +1711,23 @@ ...@@ -1689,16 +1711,23 @@
" <td>NaN</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
"</div>" "</div>"
], ],
"text/plain": [ "text/plain": [
" one three flag\n", " one two flag\n",
"a 1.0 1.0 False\n", "a 1.0 1.0 False\n",
"b 2.0 4.0 False\n", "b 2.0 NaN False\n",
"c 3.0 9.0 True\n", "c 3.0 9.0 True\n",
"d NaN NaN False" "d NaN NaN False\n",
"x NaN NaN False"
] ]
}, },
"execution_count": 60, "execution_count": 60,
...@@ -1707,7 +1736,8 @@ ...@@ -1707,7 +1736,8 @@
} }
], ],
"source": [ "source": [
"df.insert(1, \"three\", three)\n", "# inserta la columna three en la posición 1 bajo el nombre two\n",
"df.insert(1, \"two\", three)\n",
"df" "df"
] ]
}, },
...@@ -1729,19 +1759,19 @@ ...@@ -1729,19 +1759,19 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 62, "execution_count": 61,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"one 1\n", "one 1\n",
"three 1\n", "two 1\n",
"flag False\n", "flag False\n",
"Name: a, dtype: object" "Name: a, dtype: object"
] ]
}, },
"execution_count": 62, "execution_count": 61,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1752,7 +1782,7 @@ ...@@ -1752,7 +1782,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 28, "execution_count": 62,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1776,7 +1806,7 @@ ...@@ -1776,7 +1806,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 65, "execution_count": 63,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1801,7 +1831,7 @@ ...@@ -1801,7 +1831,7 @@
" <tr style=\"text-align: right;\">\n", " <tr style=\"text-align: right;\">\n",
" <th></th>\n", " <th></th>\n",
" <th>one</th>\n", " <th>one</th>\n",
" <th>three</th>\n", " <th>two</th>\n",
" <th>flag</th>\n", " <th>flag</th>\n",
" </tr>\n", " </tr>\n",
" </thead>\n", " </thead>\n",
...@@ -1815,7 +1845,7 @@ ...@@ -1815,7 +1845,7 @@
" <tr>\n", " <tr>\n",
" <th>b</th>\n", " <th>b</th>\n",
" <td>2.0</td>\n", " <td>2.0</td>\n",
" <td>4.0</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" </tbody>\n", " </tbody>\n",
...@@ -1823,12 +1853,12 @@ ...@@ -1823,12 +1853,12 @@
"</div>" "</div>"
], ],
"text/plain": [ "text/plain": [
" one three flag\n", " one two flag\n",
"a 1.0 1.0 False\n", "a 1.0 1.0 False\n",
"b 2.0 4.0 False" "b 2.0 NaN False"
] ]
}, },
"execution_count": 65, "execution_count": 63,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1842,7 +1872,7 @@ ...@@ -1842,7 +1872,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 5.4 Ejercicios\n", "## 5.4 Ejercicios\n",
"Los siguentes ejercicios de realizann con los dato de *iris.csv *" "Los siguentes ejercicios de realizann con los dato de *iris.csv*"
] ]
}, },
{ {
......
...@@ -24,11 +24,7 @@ ...@@ -24,11 +24,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
<<<<<<< HEAD
"execution_count": 2, "execution_count": 2,
=======
"execution_count": 1,
>>>>>>> master
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -177,11 +173,7 @@ ...@@ -177,11 +173,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
<<<<<<< HEAD
"execution_count": 3, "execution_count": 3,
=======
"execution_count": 7,
>>>>>>> master
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -620,9 +612,9 @@ ...@@ -620,9 +612,9 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[2., 2., 9., 4.],\n", "array([[2., 9., 8., 6.],\n",
" [6., 6., 3., 6.],\n", " [8., 4., 2., 9.],\n",
" [7., 9., 9., 8.]])" " [1., 1., 4., 5.]])"
] ]
}, },
"execution_count": 26, "execution_count": 26,
...@@ -663,12 +655,12 @@ ...@@ -663,12 +655,12 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[2., 2.],\n", "array([[2., 9.],\n",
" [9., 4.],\n", " [8., 6.],\n",
" [6., 6.],\n", " [8., 4.],\n",
" [3., 6.],\n", " [2., 9.],\n",
" [7., 9.],\n", " [1., 1.],\n",
" [9., 8.]])" " [4., 5.]])"
] ]
}, },
"execution_count": 28, "execution_count": 28,
...@@ -688,10 +680,10 @@ ...@@ -688,10 +680,10 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[2., 6., 7.],\n", "array([[2., 8., 1.],\n",
" [2., 6., 9.],\n", " [9., 4., 1.],\n",
" [9., 3., 9.],\n", " [8., 2., 4.],\n",
" [4., 6., 8.]])" " [6., 9., 5.]])"
] ]
}, },
"execution_count": 29, "execution_count": 29,
...@@ -754,9 +746,9 @@ ...@@ -754,9 +746,9 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[2., 2., 9., 4.],\n", "array([[2., 9., 8., 6.],\n",
" [6., 6., 3., 6.],\n", " [8., 4., 2., 9.],\n",
" [7., 9., 9., 8.]])" " [1., 1., 4., 5.]])"
] ]
}, },
"execution_count": 32, "execution_count": 32,
...@@ -780,11 +772,7 @@ ...@@ -780,11 +772,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
<<<<<<< HEAD
"execution_count": 17,
=======
"execution_count": 33, "execution_count": 33,
>>>>>>> master
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -814,38 +802,22 @@ ...@@ -814,38 +802,22 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
<<<<<<< HEAD "execution_count": 18,
"execution_count": 23,
=======
"execution_count": 34,
>>>>>>> master
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"1 7 7\n", "Metodo sin transpuesta\n",
"2 9 18\n", "[[58, 64], [139, 154]]\n",
"3 11 33\n", "Metodo con transpuesta\n",
"------ 58\n",
"1 8 8\n",
"2 10 20\n",
"3 12 36\n",
"------ 64\n",
"4 7 28\n",
"5 9 45\n",
"6 11 66\n",
"------ 139\n",
"4 8 32\n",
"5 10 50\n",
"6 12 72\n",
"------ 154\n",
"[[58, 64], [139, 154]]\n" "[[58, 64], [139, 154]]\n"
] ]
} }
], ],
"source": [ "source": [
"import numpy as np\n",
"def getProdMat(A,B):\n", "def getProdMat(A,B):\n",
" prodmat = []\n", " prodmat = []\n",
" if(len(A) == len(B[0])):\n", " if(len(A) == len(B[0])):\n",
...@@ -855,17 +827,35 @@ ...@@ -855,17 +827,35 @@
" auxSuma = 0\n", " auxSuma = 0\n",
" for subIndiceA, subElemA in enumerate(elemA):\n", " for subIndiceA, subElemA in enumerate(elemA):\n",
" auxSuma += subElemA*B[subIndiceA][cont]\n", " auxSuma += subElemA*B[subIndiceA][cont]\n",
" print(subElemA, \" \", B[subIndiceA][cont], \" \", subElemA*B[subIndiceA][cont])\n", " #print(subElemA, \" \", B[subIndiceA][cont], \" \", subElemA*B[subIndiceA][cont])\n",
" elemProdMat.append(auxSuma)\n", " elemProdMat.append(auxSuma)\n",
" print(\"------\", auxSuma)\n", " #print(\"------\", auxSuma)\n",
" prodmat.append(elemProdMat)\n", " prodmat.append(elemProdMat)\n",
" return prodmat\n", " return prodmat\n",
" else:\n", " else:\n",
" return \"La matriz debe ser A=mxn y B=nxp\"\n", " return \"La matriz debe ser A=mxn y B=nxp\"\n",
" \n", " \n",
"def getProdMat2(A,B):\n",
" A = np.array(A)\n",
" B = np.array(B) \n",
" prodmat = []\n",
" if(len(A) == len(B[0])):\n",
" for r in A:\n",
" aux = []\n",
" for p in B.T:\n",
" aux.append(sum(r*p))\n",
" #print(sum(r*p))\n",
" prodmat.append(aux)\n",
" return prodmat\n",
" else:\n",
" return \"La matriz debe ser A=mxn y B=nxp\"\n",
" \n",
"A = [[1,2,3],[4,5,6]]\n", "A = [[1,2,3],[4,5,6]]\n",
"B = [[7,8],[9,10],[11,12]]\n", "B = [[7,8],[9,10],[11,12]]\n",
"print(getProdMat(A,B))" "print(\"Metodo sin transpuesta\")\n",
"print(getProdMat(A,B))\n",
"print(\"Metodo con transpuesta\")\n",
"print(getProdMat2(A,B))"
] ]
}, },
{ {
...@@ -908,6 +898,13 @@ ...@@ -908,6 +898,13 @@
"[Wikipedia](https://en.wikipedia.org/wiki/Gaussian_elimination): En matemáticas, la eliminación de Gauss Jordan, llamada así en honor de Carl Friedrich Gauss y Wilhelm Jordan es un algoritmo del álgebra lineal que se usa para determinar las soluciones de un sistema de ecuaciones lineales, para encontrar matrices e inversas. Un sistema de ecuaciones se resuelve por el método de Gauss cuando se obtienen sus soluciones mediante la reducción del sistema dado a otro equivalente en el que cada ecuación tiene una incógnita menos que la anterior. El método de Gauss transforma la matriz de coeficientes en una matriz triangular superior. El método de Gauss-Jordan continúa el proceso de transformación hasta obtener una matriz diagonal" "[Wikipedia](https://en.wikipedia.org/wiki/Gaussian_elimination): En matemáticas, la eliminación de Gauss Jordan, llamada así en honor de Carl Friedrich Gauss y Wilhelm Jordan es un algoritmo del álgebra lineal que se usa para determinar las soluciones de un sistema de ecuaciones lineales, para encontrar matrices e inversas. Un sistema de ecuaciones se resuelve por el método de Gauss cuando se obtienen sus soluciones mediante la reducción del sistema dado a otro equivalente en el que cada ecuación tiene una incógnita menos que la anterior. El método de Gauss transforma la matriz de coeficientes en una matriz triangular superior. El método de Gauss-Jordan continúa el proceso de transformación hasta obtener una matriz diagonal"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -940,7 +937,7 @@ ...@@ -940,7 +937,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 35, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -956,11 +953,11 @@ ...@@ -956,11 +953,11 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"a -0.192610\n", "a 1.085164\n",
"b 0.957230\n", "b 0.684054\n",
"c -0.917233\n", "c -3.137046\n",
"d 1.156523\n", "d -0.780916\n",
"e -0.539532\n", "e 0.497413\n",
"dtype: float64" "dtype: float64"
] ]
}, },
...@@ -982,11 +979,11 @@ ...@@ -982,11 +979,11 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"0 -0.856313\n", "0 -0.165303\n",
"1 -0.342923\n", "1 0.089697\n",
"2 -1.398583\n", "2 -1.680879\n",
"3 0.170869\n", "3 -0.160729\n",
"4 1.049196\n", "4 0.235082\n",
"dtype: float64" "dtype: float64"
] ]
}, },
...@@ -1025,22 +1022,19 @@ ...@@ -1025,22 +1022,19 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 39, "execution_count": 22,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "ename": "NameError",
"text/plain": [ "evalue": "name 'null' is not defined",
"b 1.0\n", "output_type": "error",
"c 2.0\n", "traceback": [
"d NaN\n", "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"a 0.0\n", "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"dtype: float64" "\u001b[0;32m<ipython-input-22-3cd398298f6f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0md\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m'a'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m0.\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'b'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m1.\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'c'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m2.\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0md\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m'a'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m0.\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'b'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m1.\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'c'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;36m2.\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'd'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0mnull\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;31m#pd.Series(d, index=['b', 'c', 'd', 'a'])\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'null' is not defined"
] ]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [ "source": [
...@@ -1063,7 +1057,7 @@ ...@@ -1063,7 +1057,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"-0.19261011238315226" "1.0851635954341003"
] ]
}, },
"execution_count": 40, "execution_count": 40,
...@@ -1083,9 +1077,9 @@ ...@@ -1083,9 +1077,9 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"a -0.192610\n", "a 1.085164\n",
"b 0.957230\n", "b 0.684054\n",
"c -0.917233\n", "c -3.137046\n",
"dtype: float64" "dtype: float64"
] ]
}, },
...@@ -1106,8 +1100,9 @@ ...@@ -1106,8 +1100,9 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"b 0.957230\n", "a 1.085164\n",
"d 1.156523\n", "b 0.684054\n",
"e 0.497413\n",
"dtype: float64" "dtype: float64"
] ]
}, },
...@@ -1128,11 +1123,11 @@ ...@@ -1128,11 +1123,11 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"a -0.385220\n", "a 2.170327\n",
"b 1.914460\n", "b 1.368108\n",
"c -1.834466\n", "c -6.274092\n",
"d 2.313046\n", "d -1.561832\n",
"e -1.079065\n", "e 0.994826\n",
"dtype: float64" "dtype: float64"
] ]
}, },
...@@ -1153,10 +1148,10 @@ ...@@ -1153,10 +1148,10 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"a False\n", "a True\n",
"b True\n", "b True\n",
"c False\n", "c False\n",
"d True\n", "d False\n",
"e False\n", "e False\n",
"dtype: bool" "dtype: bool"
] ]
...@@ -1178,7 +1173,7 @@ ...@@ -1178,7 +1173,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"-0.19261011238315226" "1.0851635954341003"
] ]
}, },
"execution_count": 45, "execution_count": 45,
...@@ -1199,7 +1194,7 @@ ...@@ -1199,7 +1194,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 46, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -1209,7 +1204,7 @@ ...@@ -1209,7 +1204,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 47, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1218,7 +1213,7 @@ ...@@ -1218,7 +1213,7 @@
"array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])" "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
] ]
}, },
"execution_count": 47, "execution_count": 5,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1229,7 +1224,7 @@ ...@@ -1229,7 +1224,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 48, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1248,7 +1243,7 @@ ...@@ -1248,7 +1243,7 @@
"dtype: int64" "dtype: int64"
] ]
}, },
"execution_count": 48, "execution_count": 6,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1259,32 +1254,48 @@ ...@@ -1259,32 +1254,48 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 49, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "name": "stdout",
"text/plain": [ "output_type": "stream",
"array([ 4, 6, 8, 10, 12, 14])" "text": [
"[0 1 2 3 4 5]\n",
"[4 5 6 7 8 9]\n",
"[ 4 6 8 10 12 14]\n"
] ]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [ "source": [
"(a[:6]+a[4:])" "print(a[:6])\n",
"print(a[4:])\n",
"print(a[:6]+a[4:])"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 50, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "name": "stdout",
"text/plain": [ "output_type": "stream",
"text": [
"0 0\n",
"1 1\n",
"2 2\n",
"3 3\n",
"4 4\n",
"5 5\n",
"dtype: int64\n",
"4 4\n",
"5 5\n",
"6 6\n",
"7 7\n",
"8 8\n",
"9 9\n",
"dtype: int64\n",
"0 NaN\n", "0 NaN\n",
"1 NaN\n", "1 NaN\n",
"2 NaN\n", "2 NaN\n",
...@@ -1295,16 +1306,14 @@ ...@@ -1295,16 +1306,14 @@
"7 NaN\n", "7 NaN\n",
"8 NaN\n", "8 NaN\n",
"9 NaN\n", "9 NaN\n",
"dtype: float64" "dtype: float64\n"
] ]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [ "source": [
"(s[:6]+s[4:])" "print(s[:6])\n",
"print(s[4:])\n",
"print(s[:6]+s[4:])"
] ]
}, },
{ {
...@@ -1312,7 +1321,7 @@ ...@@ -1312,7 +1321,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"### 5.3.2 DataFrame\n", "### 5.3.2 DataFrame\n",
"DataFrame es un estructura bidimensiona etiquetada con columnas que pueden ser de diferentes tipos, es el objeto mas usado en pandas, se puede pensar en ella como un diccionario de **Series**. **DataFrame** acepta diferentes tipos de entradas como:\n", "DataFrame es un estructura bidimensional etiquetada con columnas que pueden ser de diferentes tipos, es el objeto mas usado en pandas, se puede pensar en ella como un diccionario de **Series**. **DataFrame** acepta diferentes tipos de entradas como:\n",
"* Diccionarios de arreglos unidimensionales, listas dicionarios o series. \n", "* Diccionarios de arreglos unidimensionales, listas dicionarios o series. \n",
"* 2-D numpy.ndarray\n", "* 2-D numpy.ndarray\n",
"* Series\n", "* Series\n",
...@@ -1321,7 +1330,7 @@ ...@@ -1321,7 +1330,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 51, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -1331,17 +1340,17 @@ ...@@ -1331,17 +1340,17 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 52, "execution_count": 22,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"d = {'one': pd.Series([1., 2., 3.], index=['a', 'b', 'c']),\n", "d = {'one': pd.Series([1., 2., 3.], index=['a', 'b', 'c']),\n",
" 'two': pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])}" " 'two': pd.Series([1., 2., 3., 4.], index=['a', 'x', 'c', 'd'])}"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 53, "execution_count": 23,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -1350,7 +1359,7 @@ ...@@ -1350,7 +1359,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 54, "execution_count": 24,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1387,7 +1396,7 @@ ...@@ -1387,7 +1396,7 @@
" <tr>\n", " <tr>\n",
" <th>b</th>\n", " <th>b</th>\n",
" <td>2.0</td>\n", " <td>2.0</td>\n",
" <td>2.0</td>\n", " <td>NaN</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>c</th>\n", " <th>c</th>\n",
...@@ -1399,6 +1408,11 @@ ...@@ -1399,6 +1408,11 @@
" <td>NaN</td>\n", " <td>NaN</td>\n",
" <td>4.0</td>\n", " <td>4.0</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
"</div>" "</div>"
...@@ -1406,12 +1420,13 @@ ...@@ -1406,12 +1420,13 @@
"text/plain": [ "text/plain": [
" one two\n", " one two\n",
"a 1.0 1.0\n", "a 1.0 1.0\n",
"b 2.0 2.0\n", "b 2.0 NaN\n",
"c 3.0 3.0\n", "c 3.0 3.0\n",
"d NaN 4.0" "d NaN 4.0\n",
"x NaN 2.0"
] ]
}, },
"execution_count": 54, "execution_count": 24,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1429,7 +1444,7 @@ ...@@ -1429,7 +1444,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 55, "execution_count": 25,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1439,10 +1454,11 @@ ...@@ -1439,10 +1454,11 @@
"b 2.0\n", "b 2.0\n",
"c 3.0\n", "c 3.0\n",
"d NaN\n", "d NaN\n",
"x NaN\n",
"Name: one, dtype: float64" "Name: one, dtype: float64"
] ]
}, },
"execution_count": 55, "execution_count": 25,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1453,7 +1469,7 @@ ...@@ -1453,7 +1469,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 56, "execution_count": 26,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1494,8 +1510,8 @@ ...@@ -1494,8 +1510,8 @@
" <tr>\n", " <tr>\n",
" <th>b</th>\n", " <th>b</th>\n",
" <td>2.0</td>\n", " <td>2.0</td>\n",
" <td>2.0</td>\n", " <td>NaN</td>\n",
" <td>4.0</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
...@@ -1512,6 +1528,13 @@ ...@@ -1512,6 +1528,13 @@
" <td>NaN</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>2.0</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
"</div>" "</div>"
...@@ -1519,12 +1542,13 @@ ...@@ -1519,12 +1542,13 @@
"text/plain": [ "text/plain": [
" one two three flag\n", " one two three flag\n",
"a 1.0 1.0 1.0 False\n", "a 1.0 1.0 1.0 False\n",
"b 2.0 2.0 4.0 False\n", "b 2.0 NaN NaN False\n",
"c 3.0 3.0 9.0 True\n", "c 3.0 3.0 9.0 True\n",
"d NaN 4.0 NaN False" "d NaN 4.0 NaN False\n",
"x NaN 2.0 NaN False"
] ]
}, },
"execution_count": 56, "execution_count": 26,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1604,6 +1628,11 @@ ...@@ -1604,6 +1628,11 @@
" <td>NaN</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
"</div>" "</div>"
...@@ -1613,7 +1642,8 @@ ...@@ -1613,7 +1642,8 @@
"a 1.0 False\n", "a 1.0 False\n",
"b 2.0 False\n", "b 2.0 False\n",
"c 3.0 True\n", "c 3.0 True\n",
"d NaN False" "d NaN False\n",
"x NaN False"
] ]
}, },
"execution_count": 59, "execution_count": 59,
...@@ -1652,7 +1682,7 @@ ...@@ -1652,7 +1682,7 @@
" <tr style=\"text-align: right;\">\n", " <tr style=\"text-align: right;\">\n",
" <th></th>\n", " <th></th>\n",
" <th>one</th>\n", " <th>one</th>\n",
" <th>three</th>\n", " <th>two</th>\n",
" <th>flag</th>\n", " <th>flag</th>\n",
" </tr>\n", " </tr>\n",
" </thead>\n", " </thead>\n",
...@@ -1666,7 +1696,7 @@ ...@@ -1666,7 +1696,7 @@
" <tr>\n", " <tr>\n",
" <th>b</th>\n", " <th>b</th>\n",
" <td>2.0</td>\n", " <td>2.0</td>\n",
" <td>4.0</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
...@@ -1681,16 +1711,23 @@ ...@@ -1681,16 +1711,23 @@
" <td>NaN</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n",
" <th>x</th>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
"</div>" "</div>"
], ],
"text/plain": [ "text/plain": [
" one three flag\n", " one two flag\n",
"a 1.0 1.0 False\n", "a 1.0 1.0 False\n",
"b 2.0 4.0 False\n", "b 2.0 NaN False\n",
"c 3.0 9.0 True\n", "c 3.0 9.0 True\n",
"d NaN NaN False" "d NaN NaN False\n",
"x NaN NaN False"
] ]
}, },
"execution_count": 60, "execution_count": 60,
...@@ -1699,7 +1736,8 @@ ...@@ -1699,7 +1736,8 @@
} }
], ],
"source": [ "source": [
"df.insert(1, \"three\", three)\n", "# inserta la columna three en la posición 1 bajo el nombre two\n",
"df.insert(1, \"two\", three)\n",
"df" "df"
] ]
}, },
...@@ -1721,19 +1759,19 @@ ...@@ -1721,19 +1759,19 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 62, "execution_count": 61,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"one 1\n", "one 1\n",
"three 1\n", "two 1\n",
"flag False\n", "flag False\n",
"Name: a, dtype: object" "Name: a, dtype: object"
] ]
}, },
"execution_count": 62, "execution_count": 61,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1744,30 +1782,45 @@ ...@@ -1744,30 +1782,45 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 63, <<<<<<< HEAD
"execution_count": 28,
=======
"execution_count": 62,
>>>>>>> master
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
<<<<<<< HEAD
"one 2\n",
"two 2\n",
"three 4\n",
"flag False\n",
"Name: b, dtype: object"
]
},
"execution_count": 28,
=======
"one 3\n", "one 3\n",
"three 9\n", "two 9\n",
"flag True\n", "flag True\n",
"Name: c, dtype: object" "Name: c, dtype: object"
] ]
}, },
"execution_count": 63, "execution_count": 62,
>>>>>>> master
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"df.iloc[2]" "df.iloc[1]"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 65, "execution_count": 63,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1792,7 +1845,7 @@ ...@@ -1792,7 +1845,7 @@
" <tr style=\"text-align: right;\">\n", " <tr style=\"text-align: right;\">\n",
" <th></th>\n", " <th></th>\n",
" <th>one</th>\n", " <th>one</th>\n",
" <th>three</th>\n", " <th>two</th>\n",
" <th>flag</th>\n", " <th>flag</th>\n",
" </tr>\n", " </tr>\n",
" </thead>\n", " </thead>\n",
...@@ -1806,7 +1859,7 @@ ...@@ -1806,7 +1859,7 @@
" <tr>\n", " <tr>\n",
" <th>b</th>\n", " <th>b</th>\n",
" <td>2.0</td>\n", " <td>2.0</td>\n",
" <td>4.0</td>\n", " <td>NaN</td>\n",
" <td>False</td>\n", " <td>False</td>\n",
" </tr>\n", " </tr>\n",
" </tbody>\n", " </tbody>\n",
...@@ -1814,12 +1867,12 @@ ...@@ -1814,12 +1867,12 @@
"</div>" "</div>"
], ],
"text/plain": [ "text/plain": [
" one three flag\n", " one two flag\n",
"a 1.0 1.0 False\n", "a 1.0 1.0 False\n",
"b 2.0 4.0 False" "b 2.0 NaN False"
] ]
}, },
"execution_count": 65, "execution_count": 63,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1833,12 +1886,16 @@ ...@@ -1833,12 +1886,16 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 5.4 Ejercicios\n", "## 5.4 Ejercicios\n",
"Los siguentes ejercicios de realizann con los dato de *iris.csv *" "Los siguentes ejercicios de realizann con los dato de *iris.csv*"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 71, <<<<<<< HEAD
"execution_count": 10,
=======
"execution_count": 64,
>>>>>>> master
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1923,7 +1980,11 @@ ...@@ -1923,7 +1980,11 @@
"4 5.0 3.6 1.4 0.2 setosa" "4 5.0 3.6 1.4 0.2 setosa"
] ]
}, },
"execution_count": 71, <<<<<<< HEAD
"execution_count": 10,
=======
"execution_count": 64,
>>>>>>> master
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1944,127 +2005,2006 @@ ...@@ -1944,127 +2005,2006 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 30,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": []
},
{ {
"cell_type": "markdown", "data": {
"metadata": {}, "text/plain": [
"source": [ "150"
"### 5.4.2 ¿Cual es el numero de columnas en el conjunto de datos?"
] ]
}, },
{ "execution_count": 30,
"cell_type": "code",
"execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "output_type": "execute_result"
"source": [] }
],
"source": [
"len(iris.index)"
]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"### 5.4.3 Imprime el nombre de todas las columnas" "### 5.4.2 ¿Cual es el numero de columnas en el conjunto de datos?"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 31,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": []
},
{ {
"cell_type": "markdown", "data": {
"metadata": {}, "text/plain": [
"source": [ "5"
"### 5.4.4 ¿Cual es el nombre de la columna 4?"
] ]
}, },
{ "execution_count": 31,
"cell_type": "code",
"execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "output_type": "execute_result"
"source": [] }
],
"source": [
"len(iris.columns)"
]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"### 5.4.5 Selecciona las columnas, \"sepal_length\" y \"petal_length\"" "### 5.4.3 Imprime el nombre de todas las columnas"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 34,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": []
},
{ {
"cell_type": "markdown", "name": "stdout",
"metadata": {}, "output_type": "stream",
"text": [
"['sepal_length' 'sepal_width' 'petal_length' 'petal_width' 'species']\n"
]
}
],
"source": [ "source": [
"### 5.4.6 Selecciona las filas en donde \"sepal_length\" sea mayor a 4.8" "print(iris.columns.values)"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"### 5.4.7 Agrega una nueva columna que sea la muliplicacion de \"petal_length\" por \"petal_width\"" "### 5.4.4 ¿Cual es el nombre de la columna 4?"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 37,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": [] {
"name": "stdout",
"output_type": "stream",
"text": [
"petal_width\n"
]
}
],
"source": [
"print(iris.columns[3])"
]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"### 5.4.8 Encuentra el promedio por especie de cada columna." "### 5.4.5 Selecciona las columnas, \"sepal_length\" y \"petal_length\""
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 41,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": [] {
} "data": {
], "text/html": [
"metadata": { "<div>\n",
"kernelspec": { "<style scoped>\n",
"display_name": "Python 3", " .dataframe tbody tr th:only-of-type {\n",
"language": "python", " vertical-align: middle;\n",
"name": "python3" " }\n",
}, "\n",
"language_info": { " .dataframe tbody tr th {\n",
"codemirror_mode": { " vertical-align: top;\n",
"name": "ipython", " }\n",
"version": 3 "\n",
}, " .dataframe thead th {\n",
"file_extension": ".py", " text-align: right;\n",
"mimetype": "text/x-python", " }\n",
"name": "python", "</style>\n",
"nbconvert_exporter": "python", "<table border=\"1\" class=\"dataframe\">\n",
"pygments_lexer": "ipython3", " <thead>\n",
"version": "3.6.7" " <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sepal_length</th>\n",
" <th>petal_length</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>5.1</td>\n",
" <td>1.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4.9</td>\n",
" <td>1.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>4.7</td>\n",
" <td>1.3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4.6</td>\n",
" <td>1.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5.0</td>\n",
" <td>1.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>5.4</td>\n",
" <td>1.7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>4.6</td>\n",
" <td>1.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>5.0</td>\n",
" <td>1.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>4.4</td>\n",
" <td>1.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>4.9</td>\n",
" <td>1.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>5.4</td>\n",
" <td>1.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>4.8</td>\n",
" <td>1.6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>4.8</td>\n",
" <td>1.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>4.3</td>\n",
" <td>1.1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>5.8</td>\n",
" <td>1.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>5.7</td>\n",
" <td>1.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>5.4</td>\n",
" <td>1.3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>5.1</td>\n",
" <td>1.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>5.7</td>\n",
" <td>1.7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>5.1</td>\n",
" <td>1.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>5.4</td>\n",
" <td>1.7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>5.1</td>\n",
" <td>1.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>4.6</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>5.1</td>\n",
" <td>1.7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>4.8</td>\n",
" <td>1.9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>5.0</td>\n",
" <td>1.6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>5.0</td>\n",
" <td>1.6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>5.2</td>\n",
" <td>1.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>5.2</td>\n",
" <td>1.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>4.7</td>\n",
" <td>1.6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>120</th>\n",
" <td>6.9</td>\n",
" <td>5.7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>121</th>\n",
" <td>5.6</td>\n",
" <td>4.9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>122</th>\n",
" <td>7.7</td>\n",
" <td>6.7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>123</th>\n",
" <td>6.3</td>\n",
" <td>4.9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>124</th>\n",
" <td>6.7</td>\n",
" <td>5.7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>125</th>\n",
" <td>7.2</td>\n",
" <td>6.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>126</th>\n",
" <td>6.2</td>\n",
" <td>4.8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>127</th>\n",
" <td>6.1</td>\n",
" <td>4.9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>128</th>\n",
" <td>6.4</td>\n",
" <td>5.6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>129</th>\n",
" <td>7.2</td>\n",
" <td>5.8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>130</th>\n",
" <td>7.4</td>\n",
" <td>6.1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>131</th>\n",
" <td>7.9</td>\n",
" <td>6.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>132</th>\n",
" <td>6.4</td>\n",
" <td>5.6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>133</th>\n",
" <td>6.3</td>\n",
" <td>5.1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>134</th>\n",
" <td>6.1</td>\n",
" <td>5.6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>135</th>\n",
" <td>7.7</td>\n",
" <td>6.1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>136</th>\n",
" <td>6.3</td>\n",
" <td>5.6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>137</th>\n",
" <td>6.4</td>\n",
" <td>5.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>138</th>\n",
" <td>6.0</td>\n",
" <td>4.8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>139</th>\n",
" <td>6.9</td>\n",
" <td>5.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>140</th>\n",
" <td>6.7</td>\n",
" <td>5.6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>141</th>\n",
" <td>6.9</td>\n",
" <td>5.1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>142</th>\n",
" <td>5.8</td>\n",
" <td>5.1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>143</th>\n",
" <td>6.8</td>\n",
" <td>5.9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>144</th>\n",
" <td>6.7</td>\n",
" <td>5.7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>145</th>\n",
" <td>6.7</td>\n",
" <td>5.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>146</th>\n",
" <td>6.3</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>147</th>\n",
" <td>6.5</td>\n",
" <td>5.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>148</th>\n",
" <td>6.2</td>\n",
" <td>5.4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149</th>\n",
" <td>5.9</td>\n",
" <td>5.1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>150 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" sepal_length petal_length\n",
"0 5.1 1.4\n",
"1 4.9 1.4\n",
"2 4.7 1.3\n",
"3 4.6 1.5\n",
"4 5.0 1.4\n",
"5 5.4 1.7\n",
"6 4.6 1.4\n",
"7 5.0 1.5\n",
"8 4.4 1.4\n",
"9 4.9 1.5\n",
"10 5.4 1.5\n",
"11 4.8 1.6\n",
"12 4.8 1.4\n",
"13 4.3 1.1\n",
"14 5.8 1.2\n",
"15 5.7 1.5\n",
"16 5.4 1.3\n",
"17 5.1 1.4\n",
"18 5.7 1.7\n",
"19 5.1 1.5\n",
"20 5.4 1.7\n",
"21 5.1 1.5\n",
"22 4.6 1.0\n",
"23 5.1 1.7\n",
"24 4.8 1.9\n",
"25 5.0 1.6\n",
"26 5.0 1.6\n",
"27 5.2 1.5\n",
"28 5.2 1.4\n",
"29 4.7 1.6\n",
".. ... ...\n",
"120 6.9 5.7\n",
"121 5.6 4.9\n",
"122 7.7 6.7\n",
"123 6.3 4.9\n",
"124 6.7 5.7\n",
"125 7.2 6.0\n",
"126 6.2 4.8\n",
"127 6.1 4.9\n",
"128 6.4 5.6\n",
"129 7.2 5.8\n",
"130 7.4 6.1\n",
"131 7.9 6.4\n",
"132 6.4 5.6\n",
"133 6.3 5.1\n",
"134 6.1 5.6\n",
"135 7.7 6.1\n",
"136 6.3 5.6\n",
"137 6.4 5.5\n",
"138 6.0 4.8\n",
"139 6.9 5.4\n",
"140 6.7 5.6\n",
"141 6.9 5.1\n",
"142 5.8 5.1\n",
"143 6.8 5.9\n",
"144 6.7 5.7\n",
"145 6.7 5.2\n",
"146 6.3 5.0\n",
"147 6.5 5.2\n",
"148 6.2 5.4\n",
"149 5.9 5.1\n",
"\n",
"[150 rows x 2 columns]"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sepal_petal_length = pd.DataFrame()\n",
"sepal_petal_length[\"sepal_length\"] = iris[\"sepal_length\"]\n",
"sepal_petal_length[\"petal_length\"] = iris[\"petal_length\"]\n",
"sepal_petal_length"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.6 Selecciona las filas en donde \"sepal_length\" sea mayor a 4.8"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sepal_length</th>\n",
" <th>sepal_width</th>\n",
" <th>petal_length</th>\n",
" <th>petal_width</th>\n",
" <th>species</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4.9</td>\n",
" <td>3.0</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5.0</td>\n",
" <td>3.6</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>5.4</td>\n",
" <td>3.9</td>\n",
" <td>1.7</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>5.0</td>\n",
" <td>3.4</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>4.9</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.1</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>5.4</td>\n",
" <td>3.7</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>5.8</td>\n",
" <td>4.0</td>\n",
" <td>1.2</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>5.7</td>\n",
" <td>4.4</td>\n",
" <td>1.5</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>5.4</td>\n",
" <td>3.9</td>\n",
" <td>1.3</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.3</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>5.7</td>\n",
" <td>3.8</td>\n",
" <td>1.7</td>\n",
" <td>0.3</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>5.1</td>\n",
" <td>3.8</td>\n",
" <td>1.5</td>\n",
" <td>0.3</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>5.4</td>\n",
" <td>3.4</td>\n",
" <td>1.7</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>5.1</td>\n",
" <td>3.7</td>\n",
" <td>1.5</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>5.1</td>\n",
" <td>3.3</td>\n",
" <td>1.7</td>\n",
" <td>0.5</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>5.0</td>\n",
" <td>3.0</td>\n",
" <td>1.6</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>5.0</td>\n",
" <td>3.4</td>\n",
" <td>1.6</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>5.2</td>\n",
" <td>3.5</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>5.2</td>\n",
" <td>3.4</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31</th>\n",
" <td>5.4</td>\n",
" <td>3.4</td>\n",
" <td>1.5</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>32</th>\n",
" <td>5.2</td>\n",
" <td>4.1</td>\n",
" <td>1.5</td>\n",
" <td>0.1</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>33</th>\n",
" <td>5.5</td>\n",
" <td>4.2</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>4.9</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.1</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>35</th>\n",
" <td>5.0</td>\n",
" <td>3.2</td>\n",
" <td>1.2</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>36</th>\n",
" <td>5.5</td>\n",
" <td>3.5</td>\n",
" <td>1.3</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37</th>\n",
" <td>4.9</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.1</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>39</th>\n",
" <td>5.1</td>\n",
" <td>3.4</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40</th>\n",
" <td>5.0</td>\n",
" <td>3.5</td>\n",
" <td>1.3</td>\n",
" <td>0.3</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>43</th>\n",
" <td>5.0</td>\n",
" <td>3.5</td>\n",
" <td>1.6</td>\n",
" <td>0.6</td>\n",
" <td>setosa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>120</th>\n",
" <td>6.9</td>\n",
" <td>3.2</td>\n",
" <td>5.7</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>121</th>\n",
" <td>5.6</td>\n",
" <td>2.8</td>\n",
" <td>4.9</td>\n",
" <td>2.0</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>122</th>\n",
" <td>7.7</td>\n",
" <td>2.8</td>\n",
" <td>6.7</td>\n",
" <td>2.0</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>123</th>\n",
" <td>6.3</td>\n",
" <td>2.7</td>\n",
" <td>4.9</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>124</th>\n",
" <td>6.7</td>\n",
" <td>3.3</td>\n",
" <td>5.7</td>\n",
" <td>2.1</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>125</th>\n",
" <td>7.2</td>\n",
" <td>3.2</td>\n",
" <td>6.0</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>126</th>\n",
" <td>6.2</td>\n",
" <td>2.8</td>\n",
" <td>4.8</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>127</th>\n",
" <td>6.1</td>\n",
" <td>3.0</td>\n",
" <td>4.9</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>128</th>\n",
" <td>6.4</td>\n",
" <td>2.8</td>\n",
" <td>5.6</td>\n",
" <td>2.1</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>129</th>\n",
" <td>7.2</td>\n",
" <td>3.0</td>\n",
" <td>5.8</td>\n",
" <td>1.6</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>130</th>\n",
" <td>7.4</td>\n",
" <td>2.8</td>\n",
" <td>6.1</td>\n",
" <td>1.9</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>131</th>\n",
" <td>7.9</td>\n",
" <td>3.8</td>\n",
" <td>6.4</td>\n",
" <td>2.0</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>132</th>\n",
" <td>6.4</td>\n",
" <td>2.8</td>\n",
" <td>5.6</td>\n",
" <td>2.2</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>133</th>\n",
" <td>6.3</td>\n",
" <td>2.8</td>\n",
" <td>5.1</td>\n",
" <td>1.5</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>134</th>\n",
" <td>6.1</td>\n",
" <td>2.6</td>\n",
" <td>5.6</td>\n",
" <td>1.4</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>135</th>\n",
" <td>7.7</td>\n",
" <td>3.0</td>\n",
" <td>6.1</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>136</th>\n",
" <td>6.3</td>\n",
" <td>3.4</td>\n",
" <td>5.6</td>\n",
" <td>2.4</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>137</th>\n",
" <td>6.4</td>\n",
" <td>3.1</td>\n",
" <td>5.5</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>138</th>\n",
" <td>6.0</td>\n",
" <td>3.0</td>\n",
" <td>4.8</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>139</th>\n",
" <td>6.9</td>\n",
" <td>3.1</td>\n",
" <td>5.4</td>\n",
" <td>2.1</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>140</th>\n",
" <td>6.7</td>\n",
" <td>3.1</td>\n",
" <td>5.6</td>\n",
" <td>2.4</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>141</th>\n",
" <td>6.9</td>\n",
" <td>3.1</td>\n",
" <td>5.1</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>142</th>\n",
" <td>5.8</td>\n",
" <td>2.7</td>\n",
" <td>5.1</td>\n",
" <td>1.9</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>143</th>\n",
" <td>6.8</td>\n",
" <td>3.2</td>\n",
" <td>5.9</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>144</th>\n",
" <td>6.7</td>\n",
" <td>3.3</td>\n",
" <td>5.7</td>\n",
" <td>2.5</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>145</th>\n",
" <td>6.7</td>\n",
" <td>3.0</td>\n",
" <td>5.2</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>146</th>\n",
" <td>6.3</td>\n",
" <td>2.5</td>\n",
" <td>5.0</td>\n",
" <td>1.9</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>147</th>\n",
" <td>6.5</td>\n",
" <td>3.0</td>\n",
" <td>5.2</td>\n",
" <td>2.0</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>148</th>\n",
" <td>6.2</td>\n",
" <td>3.4</td>\n",
" <td>5.4</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149</th>\n",
" <td>5.9</td>\n",
" <td>3.0</td>\n",
" <td>5.1</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>134 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" sepal_length sepal_width petal_length petal_width species\n",
"0 5.1 3.5 1.4 0.2 setosa\n",
"1 4.9 3.0 1.4 0.2 setosa\n",
"4 5.0 3.6 1.4 0.2 setosa\n",
"5 5.4 3.9 1.7 0.4 setosa\n",
"7 5.0 3.4 1.5 0.2 setosa\n",
"9 4.9 3.1 1.5 0.1 setosa\n",
"10 5.4 3.7 1.5 0.2 setosa\n",
"14 5.8 4.0 1.2 0.2 setosa\n",
"15 5.7 4.4 1.5 0.4 setosa\n",
"16 5.4 3.9 1.3 0.4 setosa\n",
"17 5.1 3.5 1.4 0.3 setosa\n",
"18 5.7 3.8 1.7 0.3 setosa\n",
"19 5.1 3.8 1.5 0.3 setosa\n",
"20 5.4 3.4 1.7 0.2 setosa\n",
"21 5.1 3.7 1.5 0.4 setosa\n",
"23 5.1 3.3 1.7 0.5 setosa\n",
"25 5.0 3.0 1.6 0.2 setosa\n",
"26 5.0 3.4 1.6 0.4 setosa\n",
"27 5.2 3.5 1.5 0.2 setosa\n",
"28 5.2 3.4 1.4 0.2 setosa\n",
"31 5.4 3.4 1.5 0.4 setosa\n",
"32 5.2 4.1 1.5 0.1 setosa\n",
"33 5.5 4.2 1.4 0.2 setosa\n",
"34 4.9 3.1 1.5 0.1 setosa\n",
"35 5.0 3.2 1.2 0.2 setosa\n",
"36 5.5 3.5 1.3 0.2 setosa\n",
"37 4.9 3.1 1.5 0.1 setosa\n",
"39 5.1 3.4 1.5 0.2 setosa\n",
"40 5.0 3.5 1.3 0.3 setosa\n",
"43 5.0 3.5 1.6 0.6 setosa\n",
".. ... ... ... ... ...\n",
"120 6.9 3.2 5.7 2.3 virginica\n",
"121 5.6 2.8 4.9 2.0 virginica\n",
"122 7.7 2.8 6.7 2.0 virginica\n",
"123 6.3 2.7 4.9 1.8 virginica\n",
"124 6.7 3.3 5.7 2.1 virginica\n",
"125 7.2 3.2 6.0 1.8 virginica\n",
"126 6.2 2.8 4.8 1.8 virginica\n",
"127 6.1 3.0 4.9 1.8 virginica\n",
"128 6.4 2.8 5.6 2.1 virginica\n",
"129 7.2 3.0 5.8 1.6 virginica\n",
"130 7.4 2.8 6.1 1.9 virginica\n",
"131 7.9 3.8 6.4 2.0 virginica\n",
"132 6.4 2.8 5.6 2.2 virginica\n",
"133 6.3 2.8 5.1 1.5 virginica\n",
"134 6.1 2.6 5.6 1.4 virginica\n",
"135 7.7 3.0 6.1 2.3 virginica\n",
"136 6.3 3.4 5.6 2.4 virginica\n",
"137 6.4 3.1 5.5 1.8 virginica\n",
"138 6.0 3.0 4.8 1.8 virginica\n",
"139 6.9 3.1 5.4 2.1 virginica\n",
"140 6.7 3.1 5.6 2.4 virginica\n",
"141 6.9 3.1 5.1 2.3 virginica\n",
"142 5.8 2.7 5.1 1.9 virginica\n",
"143 6.8 3.2 5.9 2.3 virginica\n",
"144 6.7 3.3 5.7 2.5 virginica\n",
"145 6.7 3.0 5.2 2.3 virginica\n",
"146 6.3 2.5 5.0 1.9 virginica\n",
"147 6.5 3.0 5.2 2.0 virginica\n",
"148 6.2 3.4 5.4 2.3 virginica\n",
"149 5.9 3.0 5.1 1.8 virginica\n",
"\n",
"[134 rows x 5 columns]"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"iris[iris[\"sepal_length\"] > 4.8]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.7 Agrega una nueva columna que sea la muliplicacion de \"petal_length\" por \"petal_width\""
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sepal_length</th>\n",
" <th>sepal_width</th>\n",
" <th>petal_length</th>\n",
" <th>petal_width</th>\n",
" <th>species</th>\n",
" <th>petal_length_x_petal_width</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4.9</td>\n",
" <td>3.0</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>4.7</td>\n",
" <td>3.2</td>\n",
" <td>1.3</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.26</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4.6</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.30</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5.0</td>\n",
" <td>3.6</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>5.4</td>\n",
" <td>3.9</td>\n",
" <td>1.7</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" <td>0.68</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>4.6</td>\n",
" <td>3.4</td>\n",
" <td>1.4</td>\n",
" <td>0.3</td>\n",
" <td>setosa</td>\n",
" <td>0.42</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>5.0</td>\n",
" <td>3.4</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.30</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>4.4</td>\n",
" <td>2.9</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>4.9</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.1</td>\n",
" <td>setosa</td>\n",
" <td>0.15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>5.4</td>\n",
" <td>3.7</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.30</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>4.8</td>\n",
" <td>3.4</td>\n",
" <td>1.6</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>4.8</td>\n",
" <td>3.0</td>\n",
" <td>1.4</td>\n",
" <td>0.1</td>\n",
" <td>setosa</td>\n",
" <td>0.14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>4.3</td>\n",
" <td>3.0</td>\n",
" <td>1.1</td>\n",
" <td>0.1</td>\n",
" <td>setosa</td>\n",
" <td>0.11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>5.8</td>\n",
" <td>4.0</td>\n",
" <td>1.2</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.24</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>5.7</td>\n",
" <td>4.4</td>\n",
" <td>1.5</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" <td>0.60</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>5.4</td>\n",
" <td>3.9</td>\n",
" <td>1.3</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" <td>0.52</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.3</td>\n",
" <td>setosa</td>\n",
" <td>0.42</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>5.7</td>\n",
" <td>3.8</td>\n",
" <td>1.7</td>\n",
" <td>0.3</td>\n",
" <td>setosa</td>\n",
" <td>0.51</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>5.1</td>\n",
" <td>3.8</td>\n",
" <td>1.5</td>\n",
" <td>0.3</td>\n",
" <td>setosa</td>\n",
" <td>0.45</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>5.4</td>\n",
" <td>3.4</td>\n",
" <td>1.7</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>5.1</td>\n",
" <td>3.7</td>\n",
" <td>1.5</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" <td>0.60</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>4.6</td>\n",
" <td>3.6</td>\n",
" <td>1.0</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.20</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>5.1</td>\n",
" <td>3.3</td>\n",
" <td>1.7</td>\n",
" <td>0.5</td>\n",
" <td>setosa</td>\n",
" <td>0.85</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>4.8</td>\n",
" <td>3.4</td>\n",
" <td>1.9</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.38</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>5.0</td>\n",
" <td>3.0</td>\n",
" <td>1.6</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>5.0</td>\n",
" <td>3.4</td>\n",
" <td>1.6</td>\n",
" <td>0.4</td>\n",
" <td>setosa</td>\n",
" <td>0.64</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>5.2</td>\n",
" <td>3.5</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.30</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>5.2</td>\n",
" <td>3.4</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>4.7</td>\n",
" <td>3.2</td>\n",
" <td>1.6</td>\n",
" <td>0.2</td>\n",
" <td>setosa</td>\n",
" <td>0.32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>120</th>\n",
" <td>6.9</td>\n",
" <td>3.2</td>\n",
" <td>5.7</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" <td>13.11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>121</th>\n",
" <td>5.6</td>\n",
" <td>2.8</td>\n",
" <td>4.9</td>\n",
" <td>2.0</td>\n",
" <td>virginica</td>\n",
" <td>9.80</td>\n",
" </tr>\n",
" <tr>\n",
" <th>122</th>\n",
" <td>7.7</td>\n",
" <td>2.8</td>\n",
" <td>6.7</td>\n",
" <td>2.0</td>\n",
" <td>virginica</td>\n",
" <td>13.40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>123</th>\n",
" <td>6.3</td>\n",
" <td>2.7</td>\n",
" <td>4.9</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" <td>8.82</td>\n",
" </tr>\n",
" <tr>\n",
" <th>124</th>\n",
" <td>6.7</td>\n",
" <td>3.3</td>\n",
" <td>5.7</td>\n",
" <td>2.1</td>\n",
" <td>virginica</td>\n",
" <td>11.97</td>\n",
" </tr>\n",
" <tr>\n",
" <th>125</th>\n",
" <td>7.2</td>\n",
" <td>3.2</td>\n",
" <td>6.0</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" <td>10.80</td>\n",
" </tr>\n",
" <tr>\n",
" <th>126</th>\n",
" <td>6.2</td>\n",
" <td>2.8</td>\n",
" <td>4.8</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" <td>8.64</td>\n",
" </tr>\n",
" <tr>\n",
" <th>127</th>\n",
" <td>6.1</td>\n",
" <td>3.0</td>\n",
" <td>4.9</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" <td>8.82</td>\n",
" </tr>\n",
" <tr>\n",
" <th>128</th>\n",
" <td>6.4</td>\n",
" <td>2.8</td>\n",
" <td>5.6</td>\n",
" <td>2.1</td>\n",
" <td>virginica</td>\n",
" <td>11.76</td>\n",
" </tr>\n",
" <tr>\n",
" <th>129</th>\n",
" <td>7.2</td>\n",
" <td>3.0</td>\n",
" <td>5.8</td>\n",
" <td>1.6</td>\n",
" <td>virginica</td>\n",
" <td>9.28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>130</th>\n",
" <td>7.4</td>\n",
" <td>2.8</td>\n",
" <td>6.1</td>\n",
" <td>1.9</td>\n",
" <td>virginica</td>\n",
" <td>11.59</td>\n",
" </tr>\n",
" <tr>\n",
" <th>131</th>\n",
" <td>7.9</td>\n",
" <td>3.8</td>\n",
" <td>6.4</td>\n",
" <td>2.0</td>\n",
" <td>virginica</td>\n",
" <td>12.80</td>\n",
" </tr>\n",
" <tr>\n",
" <th>132</th>\n",
" <td>6.4</td>\n",
" <td>2.8</td>\n",
" <td>5.6</td>\n",
" <td>2.2</td>\n",
" <td>virginica</td>\n",
" <td>12.32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>133</th>\n",
" <td>6.3</td>\n",
" <td>2.8</td>\n",
" <td>5.1</td>\n",
" <td>1.5</td>\n",
" <td>virginica</td>\n",
" <td>7.65</td>\n",
" </tr>\n",
" <tr>\n",
" <th>134</th>\n",
" <td>6.1</td>\n",
" <td>2.6</td>\n",
" <td>5.6</td>\n",
" <td>1.4</td>\n",
" <td>virginica</td>\n",
" <td>7.84</td>\n",
" </tr>\n",
" <tr>\n",
" <th>135</th>\n",
" <td>7.7</td>\n",
" <td>3.0</td>\n",
" <td>6.1</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" <td>14.03</td>\n",
" </tr>\n",
" <tr>\n",
" <th>136</th>\n",
" <td>6.3</td>\n",
" <td>3.4</td>\n",
" <td>5.6</td>\n",
" <td>2.4</td>\n",
" <td>virginica</td>\n",
" <td>13.44</td>\n",
" </tr>\n",
" <tr>\n",
" <th>137</th>\n",
" <td>6.4</td>\n",
" <td>3.1</td>\n",
" <td>5.5</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" <td>9.90</td>\n",
" </tr>\n",
" <tr>\n",
" <th>138</th>\n",
" <td>6.0</td>\n",
" <td>3.0</td>\n",
" <td>4.8</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" <td>8.64</td>\n",
" </tr>\n",
" <tr>\n",
" <th>139</th>\n",
" <td>6.9</td>\n",
" <td>3.1</td>\n",
" <td>5.4</td>\n",
" <td>2.1</td>\n",
" <td>virginica</td>\n",
" <td>11.34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>140</th>\n",
" <td>6.7</td>\n",
" <td>3.1</td>\n",
" <td>5.6</td>\n",
" <td>2.4</td>\n",
" <td>virginica</td>\n",
" <td>13.44</td>\n",
" </tr>\n",
" <tr>\n",
" <th>141</th>\n",
" <td>6.9</td>\n",
" <td>3.1</td>\n",
" <td>5.1</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" <td>11.73</td>\n",
" </tr>\n",
" <tr>\n",
" <th>142</th>\n",
" <td>5.8</td>\n",
" <td>2.7</td>\n",
" <td>5.1</td>\n",
" <td>1.9</td>\n",
" <td>virginica</td>\n",
" <td>9.69</td>\n",
" </tr>\n",
" <tr>\n",
" <th>143</th>\n",
" <td>6.8</td>\n",
" <td>3.2</td>\n",
" <td>5.9</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" <td>13.57</td>\n",
" </tr>\n",
" <tr>\n",
" <th>144</th>\n",
" <td>6.7</td>\n",
" <td>3.3</td>\n",
" <td>5.7</td>\n",
" <td>2.5</td>\n",
" <td>virginica</td>\n",
" <td>14.25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>145</th>\n",
" <td>6.7</td>\n",
" <td>3.0</td>\n",
" <td>5.2</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" <td>11.96</td>\n",
" </tr>\n",
" <tr>\n",
" <th>146</th>\n",
" <td>6.3</td>\n",
" <td>2.5</td>\n",
" <td>5.0</td>\n",
" <td>1.9</td>\n",
" <td>virginica</td>\n",
" <td>9.50</td>\n",
" </tr>\n",
" <tr>\n",
" <th>147</th>\n",
" <td>6.5</td>\n",
" <td>3.0</td>\n",
" <td>5.2</td>\n",
" <td>2.0</td>\n",
" <td>virginica</td>\n",
" <td>10.40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>148</th>\n",
" <td>6.2</td>\n",
" <td>3.4</td>\n",
" <td>5.4</td>\n",
" <td>2.3</td>\n",
" <td>virginica</td>\n",
" <td>12.42</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149</th>\n",
" <td>5.9</td>\n",
" <td>3.0</td>\n",
" <td>5.1</td>\n",
" <td>1.8</td>\n",
" <td>virginica</td>\n",
" <td>9.18</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>150 rows × 6 columns</p>\n",
"</div>"
],
"text/plain": [
" sepal_length sepal_width petal_length petal_width species \\\n",
"0 5.1 3.5 1.4 0.2 setosa \n",
"1 4.9 3.0 1.4 0.2 setosa \n",
"2 4.7 3.2 1.3 0.2 setosa \n",
"3 4.6 3.1 1.5 0.2 setosa \n",
"4 5.0 3.6 1.4 0.2 setosa \n",
"5 5.4 3.9 1.7 0.4 setosa \n",
"6 4.6 3.4 1.4 0.3 setosa \n",
"7 5.0 3.4 1.5 0.2 setosa \n",
"8 4.4 2.9 1.4 0.2 setosa \n",
"9 4.9 3.1 1.5 0.1 setosa \n",
"10 5.4 3.7 1.5 0.2 setosa \n",
"11 4.8 3.4 1.6 0.2 setosa \n",
"12 4.8 3.0 1.4 0.1 setosa \n",
"13 4.3 3.0 1.1 0.1 setosa \n",
"14 5.8 4.0 1.2 0.2 setosa \n",
"15 5.7 4.4 1.5 0.4 setosa \n",
"16 5.4 3.9 1.3 0.4 setosa \n",
"17 5.1 3.5 1.4 0.3 setosa \n",
"18 5.7 3.8 1.7 0.3 setosa \n",
"19 5.1 3.8 1.5 0.3 setosa \n",
"20 5.4 3.4 1.7 0.2 setosa \n",
"21 5.1 3.7 1.5 0.4 setosa \n",
"22 4.6 3.6 1.0 0.2 setosa \n",
"23 5.1 3.3 1.7 0.5 setosa \n",
"24 4.8 3.4 1.9 0.2 setosa \n",
"25 5.0 3.0 1.6 0.2 setosa \n",
"26 5.0 3.4 1.6 0.4 setosa \n",
"27 5.2 3.5 1.5 0.2 setosa \n",
"28 5.2 3.4 1.4 0.2 setosa \n",
"29 4.7 3.2 1.6 0.2 setosa \n",
".. ... ... ... ... ... \n",
"120 6.9 3.2 5.7 2.3 virginica \n",
"121 5.6 2.8 4.9 2.0 virginica \n",
"122 7.7 2.8 6.7 2.0 virginica \n",
"123 6.3 2.7 4.9 1.8 virginica \n",
"124 6.7 3.3 5.7 2.1 virginica \n",
"125 7.2 3.2 6.0 1.8 virginica \n",
"126 6.2 2.8 4.8 1.8 virginica \n",
"127 6.1 3.0 4.9 1.8 virginica \n",
"128 6.4 2.8 5.6 2.1 virginica \n",
"129 7.2 3.0 5.8 1.6 virginica \n",
"130 7.4 2.8 6.1 1.9 virginica \n",
"131 7.9 3.8 6.4 2.0 virginica \n",
"132 6.4 2.8 5.6 2.2 virginica \n",
"133 6.3 2.8 5.1 1.5 virginica \n",
"134 6.1 2.6 5.6 1.4 virginica \n",
"135 7.7 3.0 6.1 2.3 virginica \n",
"136 6.3 3.4 5.6 2.4 virginica \n",
"137 6.4 3.1 5.5 1.8 virginica \n",
"138 6.0 3.0 4.8 1.8 virginica \n",
"139 6.9 3.1 5.4 2.1 virginica \n",
"140 6.7 3.1 5.6 2.4 virginica \n",
"141 6.9 3.1 5.1 2.3 virginica \n",
"142 5.8 2.7 5.1 1.9 virginica \n",
"143 6.8 3.2 5.9 2.3 virginica \n",
"144 6.7 3.3 5.7 2.5 virginica \n",
"145 6.7 3.0 5.2 2.3 virginica \n",
"146 6.3 2.5 5.0 1.9 virginica \n",
"147 6.5 3.0 5.2 2.0 virginica \n",
"148 6.2 3.4 5.4 2.3 virginica \n",
"149 5.9 3.0 5.1 1.8 virginica \n",
"\n",
" petal_length_x_petal_width \n",
"0 0.28 \n",
"1 0.28 \n",
"2 0.26 \n",
"3 0.30 \n",
"4 0.28 \n",
"5 0.68 \n",
"6 0.42 \n",
"7 0.30 \n",
"8 0.28 \n",
"9 0.15 \n",
"10 0.30 \n",
"11 0.32 \n",
"12 0.14 \n",
"13 0.11 \n",
"14 0.24 \n",
"15 0.60 \n",
"16 0.52 \n",
"17 0.42 \n",
"18 0.51 \n",
"19 0.45 \n",
"20 0.34 \n",
"21 0.60 \n",
"22 0.20 \n",
"23 0.85 \n",
"24 0.38 \n",
"25 0.32 \n",
"26 0.64 \n",
"27 0.30 \n",
"28 0.28 \n",
"29 0.32 \n",
".. ... \n",
"120 13.11 \n",
"121 9.80 \n",
"122 13.40 \n",
"123 8.82 \n",
"124 11.97 \n",
"125 10.80 \n",
"126 8.64 \n",
"127 8.82 \n",
"128 11.76 \n",
"129 9.28 \n",
"130 11.59 \n",
"131 12.80 \n",
"132 12.32 \n",
"133 7.65 \n",
"134 7.84 \n",
"135 14.03 \n",
"136 13.44 \n",
"137 9.90 \n",
"138 8.64 \n",
"139 11.34 \n",
"140 13.44 \n",
"141 11.73 \n",
"142 9.69 \n",
"143 13.57 \n",
"144 14.25 \n",
"145 11.96 \n",
"146 9.50 \n",
"147 10.40 \n",
"148 12.42 \n",
"149 9.18 \n",
"\n",
"[150 rows x 6 columns]"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"iris[\"petal_length_x_petal_width\"] = iris['petal_length'] * iris['petal_width']\n",
"iris"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.8 Encuentra el promedio por especie de cada columna."
]
},
{
"cell_type": "code",
"execution_count": 93,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sepal_length</th>\n",
" <th>sepal_width</th>\n",
" <th>petal_length</th>\n",
" <th>petal_width</th>\n",
" <th>petal_length_x_petal_width</th>\n",
" </tr>\n",
" <tr>\n",
" <th>species</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>setosa</th>\n",
" <td>5.006</td>\n",
" <td>3.418</td>\n",
" <td>1.464</td>\n",
" <td>0.244</td>\n",
" <td>0.3628</td>\n",
" </tr>\n",
" <tr>\n",
" <th>versicolor</th>\n",
" <td>5.936</td>\n",
" <td>2.770</td>\n",
" <td>4.260</td>\n",
" <td>1.326</td>\n",
" <td>5.7204</td>\n",
" </tr>\n",
" <tr>\n",
" <th>virginica</th>\n",
" <td>6.588</td>\n",
" <td>2.974</td>\n",
" <td>5.552</td>\n",
" <td>2.026</td>\n",
" <td>11.2962</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" sepal_length sepal_width petal_length petal_width \\\n",
"species \n",
"setosa 5.006 3.418 1.464 0.244 \n",
"versicolor 5.936 2.770 4.260 1.326 \n",
"virginica 6.588 2.974 5.552 2.026 \n",
"\n",
" petal_length_x_petal_width \n",
"species \n",
"setosa 0.3628 \n",
"versicolor 5.7204 \n",
"virginica 11.2962 "
]
},
"execution_count": 93,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list_species = iris.species.unique().tolist()\n",
"#list_species\n",
"iris.groupby([\"species\"]).mean()\n",
"#iris.groupby([\"species\"]).mean().describe()\n",
"#print(iris.columns)\n",
"#print(iris[iris[\"species\"] == \"setosa\"][\"sepal_length\"].mean())\n",
"#print(iris[iris[\"species\"] == \"setosa\"][\"sepal_width\"].mean())\n",
"#print(iris[iris[\"species\"] == \"setosa\"][\"petal_length\"].mean())\n",
"#print(iris[iris[\"species\"] == \"setosa\"][\"petal_width\"].mean())"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5.006"
]
},
"execution_count": 75,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"iris[iris[\"species\"] == \"setosa\"][\"sepal_length\"].mean()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# 2 ScyPy\n", "# 2. SciPy\n",
"## 2.3 Algebra Lineal" "## 2.5 MatPlotlib"
] ]
}, },
{ {
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 2.4 Estadistica" "## 2.6 Machine Learning (scikit-learn)"
] ]
}, },
{ {
...@@ -46,7 +46,11 @@ ...@@ -46,7 +46,11 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.8rc1" <<<<<<< HEAD:07-MatPlotlib&Learning.ipynb
"version": "3.6.7"
=======
"version": "3.5.3"
>>>>>>> master:07-LinearAlgebra&Learning.ipynb
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
```bash ```bash
sudo apt-get install python3 pip3 sudo apt-get install python3 pip3
python3 -m pip install --upgrade pip python3 -m pip install --upgrade pip
pip3 install jupyter pip3 install jupyter numpy pandas matplotlib sklearn
``` ```
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 3. Programacion Orientada a Objetos\n",
"## 3.1 Clases \n",
"\n",
"Las clases proporcionan un medio de agrupar datos y funcionalidad. La creación de una nueva clase crea un nuevo tipo de objeto, lo que permite crear nuevas instancias de ese objeto. Cada instancia de la clase puede tener atributos adjuntos para mantener su estado. Las instancias de clase también pueden tener métodos (definidos por su clase) para modificar su estado."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"class Dog:\n",
" tricks = [] # Variable de clase\n",
" kind = 'canine' # Variable de clase\n",
" def __init__(self, name): # Constructor de clase\n",
" self.name = name # Variable de instancia\n",
" def add_trick(self, trick):\n",
" self.tricks.append(trick)\n",
" def f(self):\n",
" var=1 # variable local al método\n",
" return var"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pastis\n"
]
}
],
"source": [
"pastis=Dog(\"pastis\")\n",
"print(pastis.name)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'canine'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Dog.kind\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "type object 'Dog' has no attribute 'name'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-5-629675d46941>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mDog\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m: type object 'Dog' has no attribute 'name'"
]
}
],
"source": [
"Dog.name"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Max'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Dog(\"Max\").name"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"Max = Dog(\"Max\")\n",
"Keeper = Dog(\"Keeper\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'canine'"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Max.kind"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'canine'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Max.kind=\"felis\"\n",
"Keeper.kind"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['roll over', 'play dead']"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Max.add_trick('roll over')\n",
"Max.add_trick('play dead')\n",
"Keeper.tricks\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"class Dog:\n",
" __kind = 'canine' # Variable de clase Privada\n",
" name = \"\"\n",
" def __init__(self, name):\n",
" self.name = name # Variable de instancia\n",
" self.tricks = [] # Variable de instancia\n",
" def add_trick(self, trick):\n",
" self.tricks.append(trick)\n",
" def get_kind(self):\n",
" return self.__kind"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "type object 'Dog' has no attribute '__kind'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-9-4cb7b0dc9a4d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mDog\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__kind\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m: type object 'Dog' has no attribute '__kind'"
]
}
],
"source": [
"Dog.__kind"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'canine'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Max = Dog(\"Max\")\n",
"Max.get_kind()\n",
"Max._Dog__kind\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Notas:\n",
"* **Self** no es una palabra reservada en Python solo una convencion.\n",
"* [\"why explicit self has to stay\", por Guido van Rossum](http://neopythonic.blogspot.com/2008/10/why-explicit-self-has-to-stay.html)\n",
"* [We are all consenting adults](https://python-guide-chinese.readthedocs.io/zh_CN/latest/writing/style.html#we-are-all-consenting-adults) Python permite muchos trucos, y algunos de ellos son potencialmente peligrosos. Un buen ejemplo es que cualquier código de cliente puede anular las propiedades y los métodos de un objeto: no hay una palabra clave \"privada\" en Python. Esta filosofía, muy diferente de los lenguajes altamente defensivos como Java, que ofrecen muchos mecanismos para evitar cualquier uso indebido, se expresa con el dicho: \"Todos somos adultos\".\n",
"\n",
"## 3.3 Decoradores \n",
"Los decoradores son una conveniencia sintáctica, que permite que un archivo fuente de Python diga qué va a hacer con el resultado de una función o una declaración de clase antes de la declaración.\n",
"\n",
"### 3.3.1 Metodos Estaticos\n",
"**@staticmethod**\n",
"Los metodos estatcos no requieren que exista una instancia de la clase y no conocen nada sobre la clase solo sus parametros de entrada.\n",
"\n",
"\n",
"### 3.3.2 Metodos de Clase\n",
"**@classmethod** Los metodos de clase n requiren que exista a una instancia de la clase y tiene acceso a las variables de clase y solo toman como entrada un unico parametro.\n",
"\n",
"### 3.3.2 Destructor\n",
"En Python, los destructores no son tan necesarios como en C ++ porque Python tiene un recolector de basura que maneja la administración de la memoria automáticamente.\n",
"El método **__del __ ()** es el método conocido como destructor en Python. Se llama cuando todas las referencias al objeto se han eliminado, es decir, cuando un objeto se recolecta como basura."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"class Dog:\n",
" __kind = 'Canis Lupus' # Variable de clase Privada\n",
" def __init__(self, name):\n",
" self.name = name # Variable de instancia\n",
" self.tricks = [] # Variable de instancia\n",
" def add_trick(self, trick):\n",
" self.tricks.append(trick)\n",
" @classmethod\n",
" def get_kind(cls):\n",
" return cls.__kind\n",
" @staticmethod\n",
" def bark(times):\n",
" print(\"Guau \"*times)\n",
" def __str__(self):\n",
" return self.name + \" es un \" + self.__kind\n",
" def __del__(self): \n",
" print(self.name + \" a muerto\") "
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau Guau \n"
]
}
],
"source": [
"Dog.bark(30)\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Canis Lupus'"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Dog.get_kind()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3.4 Herencia"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"class Pet():\n",
" def __init__(self, owner_name):\n",
" self.owner=owner_name"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"class Malinois(Dog, Pet):\n",
" __breed = \"Malinois\"\n",
" def __init__(self, name, ownername):\n",
" Dog.__init__(self, name)\n",
" Pet.__init__(self, ownername)\n",
" self.tricks = [\"Fetch\"] # Variable de instancia\n",
" def fetch(self):\n",
" print(\"fetch\")\n",
" def __str__(self): #Overriding\n",
" # Obteniendo variable privada de la clase Padre\n",
" return self.name + \" es un \" + self._Dog__kind + \" de raza \" + self.__breed"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Canis Lupus\n",
"Max\n",
"['Fetch']\n",
"Alex\n",
"Max a muerto\n"
]
}
],
"source": [
"max = Malinois(\"Max\", \"Alex\")\n",
"print(max.get_kind())\n",
"print(max.name)\n",
"print(max.tricks)\n",
"print(max.owner)\n",
"del(max)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3.5 Polimorfismo"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3.7 Ejercicios\n",
"Como recordarán, el proyecto final consiste en desarrollar un periódico inteligente en el cual, un usuario podrá elegir ciertos temas de interés personal, por ejemplo: ”Política de relaciones exteriores”, ”Francia”, ”Música”, ”Pearl Jam”; y el sistema colectará noticias de diversas fuentes y deberá procesar los documentos para determinar la relevancia de los mismos con respecto a los temas de interés del usuario.\n",
"\n",
"**Instrucciones**: Lea con atención las siguientes especificaciones y diseñe las clases descritas a continuación.\n",
"Diseñe en pyhton las clases siguientes de manera que contengan los atributos y comportamientos necesarios para ser incluidas como parte del proyecto \"periódico inteligente\". No es necesario que implemente los métodos de las clases pero sí es necesario que los declare aunque estén vacios, es decir, el esqueleto de las clases. Considere el uso de los siguientes conceptos:\n",
"\n",
"* constructor\n",
"* variables de instancia\n",
"* variable de clase\n",
"* métodos de instancia\n",
"* métodos de clase\n",
"* herencia\n",
"* polimorfismo\n",
"\n",
"Además de estas clases, puede incluir algunas otras clases que considere necesario incluyendo la justificación. \n",
"\n",
"### 3.7.1 La Clase Nota\n",
"La clase Nota debe abstraer el concepto de una nota periodística; una noticia que aparece en alguna fuente informativa. Algunas características principales de las Notas es que debe pertenecer a alguna categoría como \"deportes\" o \"cultura\", deben tener un título, un autor, una fecha de publicación, entre otros atributos.\n",
"### 3.7.2 La Clase Fuente\n",
"La clase Fuente debe abstraer el concepto de una fuente informativa como por ejemplo \"La Jornada\" o \"noticias MVS\". Una característica principal de las Fuentes es que generan Notas (ver ejercicio 1). \n",
"### 3.7.3 La Clase Editor\n",
"La clase Editor debe abstraer el concepto de una persona (o robot) que se encarga de recopilar las Notas de diversas Fuentes para un determinado tema (sección). Por ejemplo un Editor de la sección \"cultura\" debe ser capaz de identificar las notas que corresponden a este tema. También debe ser capaz de consultar las Fuentes y autores que proporcionan las mejores Notas para la sección que le corresponde, es decir, es experto en uno de los temas. \n",
"### 3.7.4 La Clase Editorial\n",
"La clase Editorial debe abstraer el concepto del consejo editorial de un periódico. Es una clase muy importante para el proyecto ya que la Editorial decide cuáles notas deben aparecer en el día y determina el grado de relevancia de las notas del día para cada sección.Para ello, debe interactuar con los Reporteros para decidir las notas que deben incluirse, considerando los temas de interés y las valoraciones de los Reporteros."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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": 2
}
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment