Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
tap1012
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
tap1012
Commits
4dd91c4c
Commit
4dd91c4c
authored
Mar 09, 2019
by
Carlos David García Hernández
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ejercicio completo Numpy-Pandas
parent
e45e5657
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1682 additions
and
255 deletions
+1682
-255
05-NumPy&Pandas.ipynb
05-NumPy&Pandas.ipynb
+1682
-255
No files found.
05-NumPy&Pandas.ipynb
View file @
4dd91c4c
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
1
,
"execution_count":
9
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
" [10, 11, 12, 13, 14]], dtype=int16)"
" [10, 11, 12, 13, 14]], dtype=int16)"
]
]
},
},
"execution_count":
1
,
"execution_count":
9
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -909,6 +909,7 @@
...
@@ -909,6 +909,7 @@
" v2 (vector): Lista vacia\n",
" v2 (vector): Lista vacia\n",
" \n",
" \n",
" Yields:\n",
" Yields:\n",
" v3 (float): Un escalar\n",
" \n",
" \n",
" Examples:\n",
" Examples:\n",
" >>> prod_punto([10,20],[2,4])\n",
" >>> prod_punto([10,20],[2,4])\n",
...
@@ -931,7 +932,7 @@
...
@@ -931,7 +932,7 @@
" sumap=reduce((lambda x,y: x+y),v3)\n",
" sumap=reduce((lambda x,y: x+y),v3)\n",
" \n",
" \n",
" print(\"\\nVector 1: \"+str(v1)+\"\\n\"+\"Vector 2: \"+str(v2)+\"\\n\"+\"Suma Producto: \"+str(sumap))\n",
" print(\"\\nVector 1: \"+str(v1)+\"\\n\"+\"Vector 2: \"+str(v2)+\"\\n\"+\"Suma Producto: \"+str(sumap))\n",
" return
sumap
\n",
" return
(sumap)
\n",
"\n",
"\n",
" #return prod_punto\n",
" #return prod_punto\n",
" \n",
" \n",
...
@@ -949,7 +950,7 @@
...
@@ -949,7 +950,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
123
3,
"execution_count": 3,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -958,18 +959,48 @@
...
@@ -958,18 +959,48 @@
"'b=mat2\\nprint(b)\\nzip_b = zip(*b)\\nfor col_b in zip_b:\\n print(col_b)\\n'"
"'b=mat2\\nprint(b)\\nzip_b = zip(*b)\\nfor col_b in zip_b:\\n print(col_b)\\n'"
]
]
},
},
"execution_count":
123
3,
"execution_count": 3,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"def tamMatriz():\n",
"def tamMatriz():\n",
" '''\n",
" Función que da tamaño a un arreglo matricial\n",
" \n",
" Args:\n",
" None\n",
" \n",
" Yields:\n",
" En forma de lista devuelve:\n",
" nFila(int): Un escalar\n",
" nCol(int): Un escalar\n",
" \n",
" '''\n",
" n=int(input(\"Ingrese las filas de la matriz: \\n\"))\n",
" n=int(input(\"Ingrese las filas de la matriz: \\n\"))\n",
" m=int(input(\"Ingrese las columnas de la matriz: \\n\"))\n",
" m=int(input(\"Ingrese las columnas de la matriz: \\n\"))\n",
" return [n,m]\n",
" return [n,m]\n",
"\n",
"\n",
"def creaMatriz(nFila, nCol):\n",
"def creaMatriz(nFila, nCol):\n",
" '''\n",
" Función que introduce valores a un arreglo matricial.\n",
" \n",
" Args:\n",
" nFila(int): Un escalar\n",
" nCol(int): Un escalar\n",
" \n",
" Yields:\n",
" C(list): Lista que representa a una matriz\n",
" \n",
" Example:\n",
" mat1=[[1,2],\n",
" [3,4]]\n",
" mat2=[[2,2],\n",
" [2,2]]\n",
" C= [[6, 6],\n",
" [14, 14]]\n",
" '''\n",
" matriz = []\n",
" matriz = []\n",
" for i in range(nFila):\n",
" for i in range(nFila):\n",
" listaFila = []\n",
" listaFila = []\n",
...
@@ -1024,7 +1055,7 @@
...
@@ -1024,7 +1055,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
1243
,
"execution_count":
5
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -1034,229 +1065,97 @@
...
@@ -1034,229 +1065,97 @@
"Ingrese las filas de la matriz: \n",
"Ingrese las filas de la matriz: \n",
"2\n",
"2\n",
"Ingrese las columnas de la matriz: \n",
"Ingrese las columnas de la matriz: \n",
"2\n"
]
}
],
"source": [
"aa=tamMatriz()"
]
},
{
"cell_type": "code",
"execution_count": 782,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ingrese las filas de la matriz: \n",
"3\n",
"Ingrese las columnas de la matriz: \n",
"3\n"
]
}
],
"source": [
"bb=tamMatriz()"
]
},
{
"cell_type": "code",
"execution_count": 1095,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ingrese las filas de la matriz: \n",
"2\n",
"2\n",
"Ingrese las columnas de la matriz: \n",
"3\n"
]
}
],
"source": [
"cc=tamMatriz()"
]
},
{
"cell_type": "code",
"execution_count": 1236,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ingrese las filas de la matriz: \n",
"5\n",
"Ingrese las columnas de la matriz: \n",
"5\n"
]
}
],
"source": [
"dd=tamMatriz()"
]
},
{
"cell_type": "code",
"execution_count": 1393,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ingresa el valor del elemento0,0: \n",
"Ingresa el valor del elemento0,0: \n",
"1
400
\n",
"1\n",
"Ingresa el valor del elemento0,1: \n",
"Ingresa el valor del elemento0,1: \n",
"
970
\n",
"
2
\n",
"Ingresa el valor del elemento1,0: \n",
"Ingresa el valor del elemento1,0: \n",
"
970
\n",
"
3
\n",
"Ingresa el valor del elemento1,1: \n",
"Ingresa el valor del elemento1,1: \n",
"
878
\n"
"
4
\n"
]
]
}
}
],
],
"source": [
"source": [
"aa=tamMatriz()\n",
"mat1 = creaMatriz(aa[0],aa[1])"
"mat1 = creaMatriz(aa[0],aa[1])"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
784
,
"execution_count":
6
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"Ingrese las filas de la matriz: \n",
"2\n",
"Ingrese las columnas de la matriz: \n",
"2\n",
"Ingresa el valor del elemento0,0: \n",
"Ingresa el valor del elemento0,0: \n",
"
1
\n",
"
2
\n",
"Ingresa el valor del elemento0,1: \n",
"Ingresa el valor del elemento0,1: \n",
"2\n",
"2\n",
"Ingresa el valor del elemento0,2: \n",
"3\n",
"Ingresa el valor del elemento1,0: \n",
"Ingresa el valor del elemento1,0: \n",
"
4
\n",
"
2
\n",
"Ingresa el valor del elemento1,1: \n",
"Ingresa el valor del elemento1,1: \n",
"5\n",
"2\n"
"Ingresa el valor del elemento1,2: \n",
"6\n",
"Ingresa el valor del elemento2,0: \n",
"7\n",
"Ingresa el valor del elemento2,1: \n",
"8\n",
"Ingresa el valor del elemento2,2: \n",
"10\n"
]
]
}
}
],
],
"source": [
"source": [
"mat2=creaMatriz(bb[0],bb[1])"
"bb=tamMatriz()\n",
"mat2 = creaMatriz(bb[0],bb[1])"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
222
,
"execution_count": 1
095
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"Ingresa el valor del elemento0,0: \n",
"Ingrese las filas de la matriz: \n",
"10\n",
"2\n",
"Ingresa el valor del elemento0,1: \n",
"Ingrese las columnas de la matriz: \n",
"20\n",
"3\n"
"Ingresa el valor del elemento0,2: \n",
"30\n",
"Ingresa el valor del elemento1,0: \n",
"18\n",
"Ingresa el valor del elemento1,1: \n",
"5\n",
"Ingresa el valor del elemento1,2: \n",
"23\n"
]
]
}
}
],
],
"source": [
"source": [
"mat3=creaMatriz(cc[0],cc[1])"
"cc=tamMatriz()\n",
"mat3 = creaMatriz(cc[0],cc[1])"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 12
55
,
"execution_count": 12
36
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"Ingresa el valor del elemento0,0: \n",
"Ingrese las filas de la matriz: \n",
"1\n",
"Ingresa el valor del elemento0,1: \n",
"1\n",
"Ingresa el valor del elemento0,2: \n",
"0\n",
"Ingresa el valor del elemento0,3: \n",
"2\n",
"Ingresa el valor del elemento0,4: \n",
"-1\n",
"Ingresa el valor del elemento1,0: \n",
"0\n",
"Ingresa el valor del elemento1,1: \n",
"0\n",
"Ingresa el valor del elemento1,2: \n",
"2\n",
"Ingresa el valor del elemento1,3: \n",
"-1\n",
"Ingresa el valor del elemento1,4: \n",
"2\n",
"Ingresa el valor del elemento2,0: \n",
"0\n",
"Ingresa el valor del elemento2,1: \n",
"2\n",
"Ingresa el valor del elemento2,2: \n",
"-3\n",
"Ingresa el valor del elemento2,3: \n",
"4\n",
"Ingresa el valor del elemento2,4: \n",
"5\n",
"5\n",
"Ingresa el valor del elemento3,0: \n",
"Ingrese las columnas de la matriz: \n",
"1\n",
"5\n"
"Ingresa el valor del elemento3,1: \n",
"0\n",
"Ingresa el valor del elemento3,2: \n",
"-1\n",
"Ingresa el valor del elemento3,3: \n",
"1\n",
"Ingresa el valor del elemento3,4: \n",
"1\n",
"Ingresa el valor del elemento4,0: \n",
"0\n",
"Ingresa el valor del elemento4,1: \n",
"0\n",
"Ingresa el valor del elemento4,2: \n",
"0\n",
"Ingresa el valor del elemento4,3: \n",
"0\n",
"Ingresa el valor del elemento4,4: \n",
"4\n"
]
]
}
}
],
],
"source": [
"source": [
"mat4=creaMatriz(dd[0],dd[1])"
"dd=tamMatriz()\n",
"mat4 = creaMatriz(dd[0],dd[1])"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
10
,
"execution_count":
7
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -1269,10 +1168,10 @@
...
@@ -1269,10 +1168,10 @@
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"[[
500, 600], [1140, 1400
]]"
"[[
6, 6], [14, 14
]]"
]
]
},
},
"execution_count":
10
,
"execution_count":
7
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -1293,11 +1192,18 @@
...
@@ -1293,11 +1192,18 @@
"execution_count": 11,
"execution_count": 11,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"100\n"
]
},
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"array([[
500, 600
],\n",
"array([[
6, 6
],\n",
" [1
140, 1400
]])"
" [1
4, 14
]])"
]
]
},
},
"execution_count": 11,
"execution_count": 11,
...
@@ -1307,27 +1213,31 @@
...
@@ -1307,27 +1213,31 @@
],
],
"source": [
"source": [
"#Comprobacion con Numpy ejercicio 1\n",
"#Comprobacion con Numpy ejercicio 1\n",
"
np.matmul([10,20], [2,4]
)\n",
"
print(np.matmul([10,20], [2,4])
)\n",
"#Comprobacion con Numpy ejercicio 2\n",
"#Comprobacion con Numpy ejercicio 2\n",
"np.matmul(mat1, mat2)"
"np.matmul(mat1, mat2)"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
414
,
"execution_count": 1
2
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"name": "stdout",
"ename": "NameError",
"output_type": "stream",
"evalue": "name 'mat3' is not defined",
"text": [
"output_type": "error",
"[1. 0.69285714]\n"
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-12-6b19a936e2a1>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmat1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfloat64\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmat2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfloat64\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mz\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmat3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfloat64\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0mw\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmat4\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfloat64\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;31m#A=np.array(mmult1(x,y))\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'mat3' is not defined"
]
]
}
}
],
],
"source": [
"source": [
"x=np.array(mat1,dtype=np.float64)\n",
"x=np.array(mat1,dtype=np.float64)\n",
"y=np.array(mat2)\n",
"y=np.array(mat2
, dtype=np.float64
)\n",
"z=np.array(mat3,dtype=np.float64)\n",
"z=np.array(mat3,dtype=np.float64)\n",
"w=np.array(mat4,dtype=np.float64)\n",
"w=np.array(mat4,dtype=np.float64)\n",
"#A=np.array(mmult1(x,y))\n",
"#A=np.array(mmult1(x,y))\n",
...
@@ -1343,61 +1253,17 @@
...
@@ -1343,61 +1253,17 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1022,
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[]\n",
"[1. 2. 3.]\n"
]
},
{
"data": {
"text/plain": [
"[20, 30]"
]
},
"execution_count": 1022,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Encontrar uno\n",
"xxx=[[1,2,3],[0,5,6],[7,8,9]]\n",
"xxx1=np.array(xxx)\n",
"\n",
"xxx1=np.append(xxx1,[10,20,30])\n",
"xxx1\n",
"\n",
"a = np.array([]).reshape(0,3)\n",
"print(a)\n",
"a=np.append(a,[1,2,3])\n",
"print(a)\n",
"\n",
"x[0,:]\n",
"lineas=[]\n",
"lineas.append([5,10])\n",
"lineas.append([20,30])\n",
"lineas[-1]"
]
},
{
"cell_type": "code",
"execution_count": 1403,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"array([[
0.00304544, -0.00336455
],\n",
"array([[
-2. , 1.
],\n",
" [
-0.00336455, 0.0048560
5]])"
" [
1.5, -0.
5]])"
]
]
},
},
"execution_count": 1
40
3,
"execution_count": 13,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -1416,11 +1282,31 @@
...
@@ -1416,11 +1282,31 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 1
535
,
"execution_count": 1
4
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"class Matriz():\n",
"class Matriz():\n",
" '''\n",
" Clase que representa una matriz\n",
" \n",
" Args:\n",
" matriz (list): lista que representa una matriz (puede ser de python base o de numpy array)\n",
" \n",
" Methods:\n",
" filas(): Devuelve el numero de filas de la matriz\n",
" columnas(): Devuelve el nomero de columnas de la matriz\n",
" determinante(): Devuelve el determinante de la matriz\n",
" gauss(): Por método de eliminación Gaussiana\n",
" Calcula la matriz inversa para matrices cuadradas y con determinante\n",
" Calcula la pseudo inversa por la derecha para matrices no cuadradas\n",
" Yields:\n",
" filas(): Un escalar\n",
" columnas(): Un escalar\n",
" determinante(): Un escalar\n",
" gauss()\n",
" \n",
" '''\n",
" def __init__ (self,matriz):\n",
" def __init__ (self,matriz):\n",
" self.matriz=np.array(matriz)\n",
" self.matriz=np.array(matriz)\n",
" self.no=0\n",
" self.no=0\n",
...
@@ -1550,16 +1436,16 @@
...
@@ -1550,16 +1436,16 @@
" \n",
" \n",
" \n",
" \n",
" #Por la izquierda\n",
" #Por la izquierda\n",
" original=self.matriz\n",
"
#
original=self.matriz\n",
" y=mmult1(original.T,self.matriz)\n",
"
#
y=mmult1(original.T,self.matriz)\n",
" y=Matriz(y)\n",
"
#
y=Matriz(y)\n",
" print(y)\n",
"
#
print(y)\n",
" #print(self.matriz)\n",
" #print(self.matriz)\n",
" inve=y.gauss()\n",
"
#
inve=y.gauss()\n",
" #print(inve)\n",
" #print(inve)\n",
" soluI=mmult1(inve,original.T)\n",
"
#
soluI=mmult1(inve,original.T)\n",
" \n",
" \n",
" return(soluD
, soluI
)\n",
" return(soluD)\n",
" \n",
" \n",
" \n",
" \n",
" def __str__ (self):\n",
" def __str__ (self):\n",
...
@@ -1587,7 +1473,7 @@
...
@@ -1587,7 +1473,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 15
38
,
"execution_count": 15
45
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -1805,7 +1691,7 @@
...
@@ -1805,7 +1691,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 15
39
,
"execution_count": 15
46
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -1849,28 +1735,20 @@
...
@@ -1849,28 +1735,20 @@
" [-0.00336455 0.00485605]]\n",
" [-0.00336455 0.00485605]]\n",
"La inversa es: \n",
"La inversa es: \n",
"\n",
"\n",
"[[0, 0], [0, 0], [0, 0]]\n",
"[[0, 0], [0, 0], [0, 0]]\n"
"[[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n",
"Soy la matriz:\n",
"[[ 424. 290. 714.]\n",
" [ 290. 425. 715.]\n",
" [ 714. 715. 1429.]]\n",
"Determinante igual a cero:\n",
"Matriz no invertible\n"
]
]
},
},
{
{
"ename": "TypeError",
"data": {
"evalue": "object of type 'int' has no len()",
"text/plain": [
"output_type": "error",
"[[-0.030107526881720432, 0.05376344086021505],\n",
"traceback": [
" [0.044086021505376334, -0.04301075268817203],\n",
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
" [0.013978494623655913, 0.010752688172043015]]"
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
]
"\u001b[0;32m<ipython-input-1539-9c911503a563>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmmatriz3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mmmatriz3\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgauss\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
},
"\u001b[0;32m<ipython-input-1535-85fa2830b7e7>\u001b[0m in \u001b[0;36mgauss\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 136\u001b[0m \u001b[0minve\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgauss\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 137\u001b[0m \u001b[0;31m#print(inve)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 138\u001b[0;31m \u001b[0msoluI\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmmult1\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minve\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0moriginal\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mT\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 139\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 140\u001b[0m \u001b[0;32mreturn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msoluD\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msoluI\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"execution_count": 1546,
"\u001b[0;32m<ipython-input-1233-130e02de5586>\u001b[0m in \u001b[0;36mmmult1\u001b[0;34m(m1, m2)\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 17\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mmmult1\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mm1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mm2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 18\u001b[0;31m \u001b[0mfila_A\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mm1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 19\u001b[0m \u001b[0mcols_A\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mm1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 20\u001b[0m \u001b[0mfila_B\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mm2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"metadata": {},
"\u001b[0;31mTypeError\u001b[0m: object of type 'int' has no len()"
"output_type": "execute_result"
]
}
}
],
],
"source": [
"source": [
...
@@ -2297,6 +2175,1555 @@
...
@@ -2297,6 +2175,1555 @@
"#En series la suma es elemento a elemento poer con respecto al índice de toda la variable\n",
"#En series la suma es elemento a elemento poer con respecto al índice de toda la variable\n",
"(s[:6]+s[4:])"
"(s[:6]+s[4:])"
]
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5.4 Ejercicios\n",
"Los siguentes ejercicios de realizann con los dato de *iris.csv *"
]
},
{
"cell_type": "code",
"execution_count": 17,
"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>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",
" </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",
" </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",
" </tbody>\n",
"</table>\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"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"iris = pd.read_csv('data/iris.csv')\n",
"iris.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.1 ¿Cual es el numero de observaciones en el conjunto de datos?"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"150"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(iris)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.2 ¿Cual es el numero de columnas en el conjunto de datos?"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5\n",
"['sepal_length' 'sepal_width' 'petal_length' 'petal_width' 'species']\n"
]
}
],
"source": [
"nombres=iris.columns.values\n",
"print(len(nombres))\n",
"print(nombres)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.4 ¿Cual es el nombre de la columna 4? (numero, no indice)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"petal_width\n"
]
}
],
"source": [
"print(nombres[3])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.4.5 Selecciona las columnas, \"sepal_length\" y \"petal_length\""
]
},
{
"cell_type": "code",
"execution_count": 26,
"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>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",
" </tbody>\n",
"</table>\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"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"iris[[\"sepal_length\",\"petal_length\"]].head(10)"
]
},
{
"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": 29,
"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",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>120</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>121</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>122</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>123</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>124</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>125</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>126</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>127</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>128</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>129</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>130</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>131</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>132</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>133</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>134</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>135</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>136</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>137</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>138</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>139</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>140</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>141</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>142</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>143</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>144</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>145</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>146</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>147</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>148</th>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>149</th>\n",
" <td>True</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>150 rows × 1 columns</p>\n",
"</div>"
],
"text/plain": [
" sepal_length\n",
"0 True\n",
"1 True\n",
"2 False\n",
"3 False\n",
"4 True\n",
"5 True\n",
"6 False\n",
"7 True\n",
"8 False\n",
"9 True\n",
"10 True\n",
"11 False\n",
"12 False\n",
"13 False\n",
"14 True\n",
"15 True\n",
"16 True\n",
"17 True\n",
"18 True\n",
"19 True\n",
"20 True\n",
"21 True\n",
"22 False\n",
"23 True\n",
"24 False\n",
"25 True\n",
"26 True\n",
"27 True\n",
"28 True\n",
"29 False\n",
".. ...\n",
"120 True\n",
"121 True\n",
"122 True\n",
"123 True\n",
"124 True\n",
"125 True\n",
"126 True\n",
"127 True\n",
"128 True\n",
"129 True\n",
"130 True\n",
"131 True\n",
"132 True\n",
"133 True\n",
"134 True\n",
"135 True\n",
"136 True\n",
"137 True\n",
"138 True\n",
"139 True\n",
"140 True\n",
"141 True\n",
"142 True\n",
"143 True\n",
"144 True\n",
"145 True\n",
"146 True\n",
"147 True\n",
"148 True\n",
"149 True\n",
"\n",
"[150 rows x 1 columns]"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"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": 71,
"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>multipicacion</th>\n",
" <th>multiplicacion</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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <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",
" <td>9.18</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>150 rows × 7 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",
" multipicacion multiplicacion \n",
"0 0.28 0.28 \n",
"1 0.28 0.28 \n",
"2 0.26 0.26 \n",
"3 0.30 0.30 \n",
"4 0.28 0.28 \n",
"5 0.68 0.68 \n",
"6 0.42 0.42 \n",
"7 0.30 0.30 \n",
"8 0.28 0.28 \n",
"9 0.15 0.15 \n",
"10 0.30 0.30 \n",
"11 0.32 0.32 \n",
"12 0.14 0.14 \n",
"13 0.11 0.11 \n",
"14 0.24 0.24 \n",
"15 0.60 0.60 \n",
"16 0.52 0.52 \n",
"17 0.42 0.42 \n",
"18 0.51 0.51 \n",
"19 0.45 0.45 \n",
"20 0.34 0.34 \n",
"21 0.60 0.60 \n",
"22 0.20 0.20 \n",
"23 0.85 0.85 \n",
"24 0.38 0.38 \n",
"25 0.32 0.32 \n",
"26 0.64 0.64 \n",
"27 0.30 0.30 \n",
"28 0.28 0.28 \n",
"29 0.32 0.32 \n",
".. ... ... \n",
"120 13.11 13.11 \n",
"121 9.80 9.80 \n",
"122 13.40 13.40 \n",
"123 8.82 8.82 \n",
"124 11.97 11.97 \n",
"125 10.80 10.80 \n",
"126 8.64 8.64 \n",
"127 8.82 8.82 \n",
"128 11.76 11.76 \n",
"129 9.28 9.28 \n",
"130 11.59 11.59 \n",
"131 12.80 12.80 \n",
"132 12.32 12.32 \n",
"133 7.65 7.65 \n",
"134 7.84 7.84 \n",
"135 14.03 14.03 \n",
"136 13.44 13.44 \n",
"137 9.90 9.90 \n",
"138 8.64 8.64 \n",
"139 11.34 11.34 \n",
"140 13.44 13.44 \n",
"141 11.73 11.73 \n",
"142 9.69 9.69 \n",
"143 13.57 13.57 \n",
"144 14.25 14.25 \n",
"145 11.96 11.96 \n",
"146 9.50 9.50 \n",
"147 10.40 10.40 \n",
"148 12.42 12.42 \n",
"149 9.18 9.18 \n",
"\n",
"[150 rows x 7 columns]"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"iris[\"multiplicacion\"]=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": 50,
"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",
" </tr>\n",
" <tr>\n",
" <th>species</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",
" </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",
" </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",
" </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"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"iris.groupby('species').mean()"
]
}
}
],
],
"metadata": {
"metadata": {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment