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
9f801124
Commit
9f801124
authored
Feb 26, 2019
by
Alejandro Molina Villegas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pandas primera parte
parent
6991deac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
146 additions
and
115 deletions
+146
-115
05-NumPy&Pandas.ipynb
05-NumPy&Pandas.ipynb
+146
-115
No files found.
05-NumPy&Pandas.ipynb
View file @
9f801124
...
@@ -812,7 +812,11 @@
...
@@ -812,7 +812,11 @@
"cell_type": "markdown",
"cell_type": "markdown",
"metadata": {},
"metadata": {},
"source": [
"source": [
"### 5.2.5 Utilizando la funcion anterior escribe otra que obtenga la pseduo-inversa de una matriz."
"### 5.2.5 Utilizando la funcion anterior escribe otra que obtenga la pseduo-inversa de una matriz.\n",
"Def: Una matriz pseudoinversa es (At * A)^-1 * At\n",
"Nota: solo las matrices cuadradas tienen inversa\n",
"Nota: Utilice arreglos de numpy\n",
"Nota: se puede usar numpy, arreglo de arreglos y transpuestas y inversas."
]
]
},
},
{
{
...
@@ -840,7 +844,7 @@
...
@@ -840,7 +844,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
41
,
"execution_count":
2
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -850,47 +854,47 @@
...
@@ -850,47 +854,47 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
51
,
"execution_count":
13
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"name": "stdout",
"text/plain": [
"output_type": "stream",
"a 0.994272\n",
"text": [
"b 0.530519\n",
"<class 'pandas.core.series.Series'>\n",
"c 1.162452\n",
"Campeche -0.582736\n",
"d -0.981436\n",
"b -0.295072\n",
"e -1.283798\n",
"a -1.100532\n",
"dtype: float64"
"d -2.259605\n",
"e 0.848816\n",
"dtype: float64\n"
]
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"s = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e'])\n",
"s = pd.Series(np.random.randn(5), index=['Campeche', 'b', 'a', 'd', 'e'])\n",
"s"
"s\n",
"print(type(s))\n",
"print(s)"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
46
,
"execution_count":
14
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"0
2.042498
\n",
"0
1.373283
\n",
"1 -0.
96407
0\n",
"1 -0.
03689
0\n",
"2 -0.
687132
\n",
"2 -0.
349894
\n",
"3
0.62330
0\n",
"3
-0.34434
0\n",
"4 1.
366322
\n",
"4 1.
142898
\n",
"dtype: float64"
"dtype: float64"
]
]
},
},
"execution_count":
46
,
"execution_count":
14
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -901,19 +905,19 @@
...
@@ -901,19 +905,19 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
47
,
"execution_count":
15
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"a 0\n",
"b 1\n",
"b 1\n",
"a 0\n",
"c 2\n",
"c 2\n",
"dtype: int64"
"dtype: int64"
]
]
},
},
"execution_count":
47
,
"execution_count":
15
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -925,7 +929,7 @@
...
@@ -925,7 +929,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
48
,
"execution_count":
16
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -938,7 +942,7 @@
...
@@ -938,7 +942,7 @@
"dtype: float64"
"dtype: float64"
]
]
},
},
"execution_count":
48
,
"execution_count":
16
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -957,118 +961,131 @@
...
@@ -957,118 +961,131 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 5
3
,
"execution_count": 5
4
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
"text/plain": [
"text/plain": [
"0.9942721192063438"
"a 0.994272\n",
"b 0.530519\n",
"c 1.162452\n",
"dtype: float64"
]
]
},
},
"execution_count": 5
3
,
"execution_count": 5
4
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"s[
0
]"
"s[
:3
]"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
54
,
"execution_count":
19
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"name": "stdout",
"text/plain": [
"output_type": "stream",
"a 0.994272\n",
"text": [
"b 0.530519\n",
"Campeche -0.582736\n",
"c 1.162452\n",
"b -0.295072\n",
"dtype: float64"
"a -1.100532\n",
"d -2.259605\n",
"e 0.848816\n",
"dtype: float64\n",
"-0.5827355449353806\n",
"-0.5827355449353806\n"
]
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"s[:3]"
"s[0]\n",
"temperatura_solsticio=s\n",
"print(s)\n",
"print(s[0])\n",
"print(temperatura_solsticio['Campeche'])"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
55
,
"execution_count":
21
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"name": "stdout",
"text/plain": [
"output_type": "stream",
"a 0.994272\n",
"text": [
"b 0.530519\n",
"<class 'pandas.core.series.Series'>\n",
"c 1.162452\n",
"Campeche -0.582736\n",
"dtype: float64"
"b -0.295072\n",
"e 0.848816\n",
"dtype: float64\n"
]
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"s[s>s.mean()]"
"serie_mayor_promedio = s[s>s.mean()]\n",
"print(type(serie_mayor_promedio))\n",
"print(serie_mayor_promedio)"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
56
,
"execution_count":
22
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"name": "stdout",
"text/plain": [
"output_type": "stream",
"a 1.988544\n",
"text": [
"b 1.061037\n",
"Campeche -1.165471\n",
"c 2.324904\n",
"b -0.590144\n",
"d -1.962872\n",
"a -2.201063\n",
"e -2.567597\n",
"d -4.519209\n",
"dtype: float64"
"e 1.697633\n",
"dtype: float64\n"
]
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"s*2"
"serie_doble=s*2\n",
"print(serie_doble)"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
57
,
"execution_count":
24
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"name": "stdout",
"text/plain": [
"output_type": "stream",
"a True\n",
"text": [
"b False\n",
"median -0.5827355449353806\n",
"c True\n",
"s Campeche -0.582736\n",
"b -0.295072\n",
"a -1.100532\n",
"d -2.259605\n",
"e 0.848816\n",
"dtype: float64\n",
"Campeche False\n",
"b True\n",
"a False\n",
"d False\n",
"d False\n",
"e Fals
e\n",
"e Tru
e\n",
"dtype: bool
"
"dtype: bool\n
"
]
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"s>s.median()"
"s>s.median()\n",
"print('median', s.median())\n",
"print('s', s)\n",
"print(s>s.median())"
]
]
},
},
{
{
...
@@ -1100,7 +1117,7 @@
...
@@ -1100,7 +1117,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
59
,
"execution_count":
32
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -1110,7 +1127,7 @@
...
@@ -1110,7 +1127,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
60
,
"execution_count":
33
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -1119,7 +1136,7 @@
...
@@ -1119,7 +1136,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":
60
,
"execution_count":
33
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -1130,7 +1147,7 @@
...
@@ -1130,7 +1147,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
62
,
"execution_count":
34
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
...
@@ -1149,7 +1166,7 @@
...
@@ -1149,7 +1166,7 @@
"dtype: int64"
"dtype: int64"
]
]
},
},
"execution_count":
62
,
"execution_count":
34
,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
"output_type": "execute_result"
}
}
...
@@ -1180,12 +1197,27 @@
...
@@ -1180,12 +1197,27 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
76
,
"execution_count":
37
,
"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",
...
@@ -1196,16 +1228,15 @@
...
@@ -1196,16 +1228,15 @@
"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": 76,
"metadata": {},
"output_type": "execute_result"
}
}
],
],
"source": [
"source": [
"(s[:6]+s[4:])"
"# En series la suma es elemento por elemento pero con respecto a índices\n",
"print(s[:6])\n",
"print(s[4:])\n",
"print(s[:6]+s[4:])"
]
]
},
},
{
{
...
...
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