From 01be6a67cb7e6a7591bc5784815cbb5deaf94ad4 Mon Sep 17 00:00:00 2001
From: Zahid Sanchez <10248069+zk97@users.noreply.github.com>
Date: Wed, 25 Mar 2020 17:59:37 -0600
Subject: [PATCH 1/4] primer commit
---
module-1/lab-resolving-git-conflicts/your-code/about-me.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/module-1/lab-resolving-git-conflicts/your-code/about-me.md b/module-1/lab-resolving-git-conflicts/your-code/about-me.md
index 30a999d50..ee8f6fcd3 100644
--- a/module-1/lab-resolving-git-conflicts/your-code/about-me.md
+++ b/module-1/lab-resolving-git-conflicts/your-code/about-me.md
@@ -1,3 +1,4 @@
+Added text Step 5
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque viverra laoreet lorem et dapibus. Integer auctor dignissim egestas. Ut id purus neque. Pellentesque imperdiet lacus in libero laoreet, at tempus felis tristique. Cras fermentum erat a dui vulputate gravida. Nulla aliquet nisi interdum nulla pretium, ac vestibulum diam congue. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus lacus risus, sodales vitae viverra quis, maximus ac ipsum. Sed consequat viverra mattis. Curabitur iaculis varius mollis.
Ut porttitor iaculis tellus bibendum euismod. Morbi porta, ante nec tempus porta, felis mi faucibus lacus, sed tristique purus nunc sed est. Aenean pulvinar urna ut lacus interdum aliquam. Pellentesque sit amet magna accumsan, sagittis metus a, volutpat velit. Mauris vitae ex vehicula, posuere nisi sed, sagittis nunc. Ut scelerisque, mi non tristique tristique, mi enim luctus nunc, eu mattis sem quam auctor nunc. Donec lobortis tellus eget blandit ultricies. Vivamus euismod metus eget leo blandit, at malesuada magna efficitur. Praesent sodales faucibus mi, ullamcorper ultrices orci. Vivamus maximus malesuada massa, nec placerat leo feugiat vel. Nam vitae eleifend enim. Nullam interdum ipsum velit, vitae faucibus lectus blandit euismod.
From 1331e0a1368cf2e5e8559a981649cae0f5603656 Mon Sep 17 00:00:00 2001
From: Zahid Sanchez <10248069+zk97@users.noreply.github.com>
Date: Wed, 25 Mar 2020 18:53:06 -0600
Subject: [PATCH 2/4] Commit new branch
---
.../lab-resolving-git-conflicts/your-code/about-me.md | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/module-1/lab-resolving-git-conflicts/your-code/about-me.md b/module-1/lab-resolving-git-conflicts/your-code/about-me.md
index 30a999d50..0ad92d2d3 100644
--- a/module-1/lab-resolving-git-conflicts/your-code/about-me.md
+++ b/module-1/lab-resolving-git-conflicts/your-code/about-me.md
@@ -1,7 +1,8 @@
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque viverra laoreet lorem et dapibus. Integer auctor dignissim egestas. Ut id purus neque. Pellentesque imperdiet lacus in libero laoreet, at tempus felis tristique. Cras fermentum erat a dui vulputate gravida. Nulla aliquet nisi interdum nulla pretium, ac vestibulum diam congue. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus lacus risus, sodales vitae viverra quis, maximus ac ipsum. Sed consequat viverra mattis. Curabitur iaculis varius mollis.
+# Who am I?
+My name is Zahid Sánchez, I'm from Mexico City and I'm a full-time student at UNAM. Last semester I took a basic data course and learned about some of the tools that python offers.
-Ut porttitor iaculis tellus bibendum euismod. Morbi porta, ante nec tempus porta, felis mi faucibus lacus, sed tristique purus nunc sed est. Aenean pulvinar urna ut lacus interdum aliquam. Pellentesque sit amet magna accumsan, sagittis metus a, volutpat velit. Mauris vitae ex vehicula, posuere nisi sed, sagittis nunc. Ut scelerisque, mi non tristique tristique, mi enim luctus nunc, eu mattis sem quam auctor nunc. Donec lobortis tellus eget blandit ultricies. Vivamus euismod metus eget leo blandit, at malesuada magna efficitur. Praesent sodales faucibus mi, ullamcorper ultrices orci. Vivamus maximus malesuada massa, nec placerat leo feugiat vel. Nam vitae eleifend enim. Nullam interdum ipsum velit, vitae faucibus lectus blandit euismod.
+# Why am I here?
+When I was about to take the data course last semester a friend of mine mentioned Ironhack was a better option, so I looked it up and decided to apply. I'm looking forward to learning more about machine learning.
-Suspendisse ut malesuada ex. Nulla ultricies nisl et nisi rhoncus sollicitudin. Vestibulum maximus iaculis ligula, nec commodo nunc ullamcorper nec. Duis quis condimentum sapien. Cras vestibulum interdum felis eu auctor. Quisque semper, magna at dapibus faucibus, felis risus semper ligula, id aliquam lectus ligula vel nisi. In hac habitasse platea dictumst. Donec arcu sapien, suscipit ac dictum et, imperdiet id tortor. Maecenas ornare sodales interdum. Mauris dictum felis eu eros vestibulum cursus. Phasellus accumsan, turpis ut malesuada sollicitudin, augue leo venenatis ante, vel convallis tellus diam sit amet lacus. Aenean eu mauris eros. Praesent ante lacus, gravida sit amet tellus nec, laoreet ultrices lacus. Integer commodo semper vestibulum. Fusce felis massa, consectetur facilisis rutrum nec, pulvinar et nisi.
-
-Morbi fermentum ultricies tortor, vehicula ultrices eros elementum a. Duis ornare aliquam facilisis. Proin aliquam tincidunt odio vitae dignissim. Sed malesuada lacinia massa, nec blandit urna auctor elementum. Duis auctor non tortor in consequat. Mauris id vestibulum risus. In eget erat sed lacus efficitur viverra sed eu est. Aliquam interdum consequat molestie. Aliquam metus nisi, blandit non semper ut, blandit vel leo. Cras dictum turpis erat, sed iaculis ligula facilisis dapibus. Aliquam posuere dignissim fermentum. Praesent at neque sit amet lectus ornare iaculis. Curabitur id urna quis lorem varius ultrices eu sit amet sapien. Curabitur maximus volutpat suscipit. Proin imperdiet elementum lacus a eleifend. Sed tempor lacus posuere diam vehicula iaculis.
+# What will I do after the bootcamp?
+I don't have anything concrete about the job I'm looking for after the bootcamp as long as I use what I learned. My goal for the future to get a job in Silicon Valley.
From 698f8fc514cf4298781d4f380115f2cd952ed32e Mon Sep 17 00:00:00 2001
From: Zahid Sanchez <10248069+zk97@users.noreply.github.com>
Date: Thu, 26 Mar 2020 00:57:03 -0600
Subject: [PATCH 3/4] commit comprenhension lists
---
.../your-code/main.ipynb | 847 +++++++++++++++++-
1 file changed, 812 insertions(+), 35 deletions(-)
diff --git a/module-1/lab-list-comprehensions/your-code/main.ipynb b/module-1/lab-list-comprehensions/your-code/main.ipynb
index c5931c41f..404314ad9 100644
--- a/module-1/lab-list-comprehensions/your-code/main.ipynb
+++ b/module-1/lab-list-comprehensions/your-code/main.ipynb
@@ -11,7 +11,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -29,10 +29,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n"
+ ]
+ }
+ ],
+ "source": [
+ "print([x for x in range (1,51)])"
+ ]
},
{
"cell_type": "markdown",
@@ -43,10 +53,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200]\n"
+ ]
+ }
+ ],
+ "source": [
+ "print([x for x in range (2,201) if x%2==0])"
+ ]
},
{
"cell_type": "markdown",
@@ -57,7 +77,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -75,10 +95,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[0.84062117, 0.48006452, 0.7876326, 0.77109654, 0.44409793, 0.09014516, 0.81835917, 0.87645456, 0.7066597, 0.09610873, 0.41247947, 0.57433389, 0.29960807, 0.42315023, 0.34452557, 0.4751035, 0.17003563, 0.46843998, 0.92796258, 0.69814654, 0.41290051, 0.19561071, 0.16284783, 0.97016248, 0.71725408, 0.87702738, 0.31244595, 0.76615487, 0.20754036, 0.57871812, 0.07214068, 0.40356048, 0.12149553, 0.53222417, 0.9976855, 0.12536346, 0.80930099, 0.50962849, 0.94555126, 0.33364763]\n"
+ ]
+ }
+ ],
+ "source": [
+ "print([x[i] for x in a for i in range(len(x))])"
+ ]
},
{
"cell_type": "markdown",
@@ -89,10 +119,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[0.84062117, 0.7876326, 0.77109654, 0.81835917, 0.87645456, 0.7066597, 0.57433389, 0.92796258, 0.69814654, 0.97016248, 0.71725408, 0.87702738, 0.76615487, 0.57871812, 0.53222417, 0.9976855, 0.80930099, 0.50962849, 0.94555126]\n"
+ ]
+ }
+ ],
+ "source": [
+ "print([x[i] for x in a for i in range(len(x)) if x[i]>=0.5])"
+ ]
},
{
"cell_type": "markdown",
@@ -103,7 +143,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
@@ -125,10 +165,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[0.55867166, 0.06210792, 0.08147297, 0.82579068, 0.91512478, 0.06833034, 0.05440634, 0.65857693, 0.30296619, 0.06769833, 0.96031863, 0.51293743, 0.09143215, 0.71893382, 0.45850679, 0.58256464, 0.59005654, 0.56266457, 0.71600294, 0.87392666, 0.11434044, 0.8694668, 0.65669313, 0.10708681, 0.07529684, 0.46470767, 0.47984544, 0.65368638, 0.14901286, 0.23760688]\n"
+ ]
+ }
+ ],
+ "source": [
+ "print([x[i][j] for x in b for i in range(len(x)) for j in range(len(x[i]))])"
+ ]
},
{
"cell_type": "markdown",
@@ -139,10 +189,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 33,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[0.08147297, 0.06833034, 0.30296619, 0.45850679, 0.11434044, 0.10708681, 0.47984544, 0.23760688]\n"
+ ]
+ }
+ ],
+ "source": [
+ "print([x[i][j] for x in b for i in range(len(x)) for j in range(len(x[i])) if j==(len(x[i])-1) and x[i][j]<=0.5])"
+ ]
},
{
"cell_type": "markdown",
@@ -153,10 +213,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 66,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['sample_file_0.csv', 'sample_file_1.csv', 'sample_file_2.csv', 'sample_file_3.csv', 'sample_file_4.csv', 'sample_file_5.csv', 'sample_file_6.csv', 'sample_file_7.csv', 'sample_file_8.csv', 'sample_file_9.csv']\n"
+ ]
+ }
+ ],
+ "source": [
+ "print([x for x in os.listdir('../data') if x.endswith('.csv')])"
+ ]
},
{
"cell_type": "markdown",
@@ -167,10 +237,342 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 65,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "df=pd.concat([pd.read_csv('../data/'+x) for x in os.listdir('../data') if x.endswith('.csv')])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 70,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 2 | \n",
+ " 3 | \n",
+ " 4 | \n",
+ " 5 | \n",
+ " 6 | \n",
+ " 7 | \n",
+ " 8 | \n",
+ " 9 | \n",
+ " 10 | \n",
+ " 11 | \n",
+ " 12 | \n",
+ " 13 | \n",
+ " 14 | \n",
+ " 15 | \n",
+ " 16 | \n",
+ " 17 | \n",
+ " 18 | \n",
+ " 19 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 0.734751 | \n",
+ " 0.195362 | \n",
+ " 0.734309 | \n",
+ " 0.598184 | \n",
+ " 0.763433 | \n",
+ " 0.263434 | \n",
+ " 0.868066 | \n",
+ " 0.058092 | \n",
+ " 0.753502 | \n",
+ " 0.587513 | \n",
+ " 0.311608 | \n",
+ " 0.178356 | \n",
+ " 0.182922 | \n",
+ " 0.147631 | \n",
+ " 0.391188 | \n",
+ " 0.816049 | \n",
+ " 0.749068 | \n",
+ " 0.293260 | \n",
+ " 0.937828 | \n",
+ " 0.880858 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 0.772607 | \n",
+ " 0.445391 | \n",
+ " 0.249642 | \n",
+ " 0.787922 | \n",
+ " 0.598583 | \n",
+ " 0.827238 | \n",
+ " 0.624126 | \n",
+ " 0.601524 | \n",
+ " 0.688753 | \n",
+ " 0.338870 | \n",
+ " 0.081595 | \n",
+ " 0.471474 | \n",
+ " 0.267443 | \n",
+ " 0.453351 | \n",
+ " 0.800716 | \n",
+ " 0.045749 | \n",
+ " 0.683793 | \n",
+ " 0.389789 | \n",
+ " 0.016787 | \n",
+ " 0.503695 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 0.226428 | \n",
+ " 0.268764 | \n",
+ " 0.694262 | \n",
+ " 0.622335 | \n",
+ " 0.063843 | \n",
+ " 0.122683 | \n",
+ " 0.815625 | \n",
+ " 0.584542 | \n",
+ " 0.032594 | \n",
+ " 0.589775 | \n",
+ " 0.764350 | \n",
+ " 0.650973 | \n",
+ " 0.565705 | \n",
+ " 0.691784 | \n",
+ " 0.265223 | \n",
+ " 0.739031 | \n",
+ " 0.560394 | \n",
+ " 0.334802 | \n",
+ " 0.517694 | \n",
+ " 0.646110 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 0.362748 | \n",
+ " 0.495430 | \n",
+ " 0.113876 | \n",
+ " 0.594149 | \n",
+ " 0.612522 | \n",
+ " 0.625204 | \n",
+ " 0.864050 | \n",
+ " 0.260279 | \n",
+ " 0.528873 | \n",
+ " 0.168043 | \n",
+ " 0.715929 | \n",
+ " 0.677014 | \n",
+ " 0.175735 | \n",
+ " 0.632370 | \n",
+ " 0.926715 | \n",
+ " 0.085675 | \n",
+ " 0.120525 | \n",
+ " 0.141746 | \n",
+ " 0.771144 | \n",
+ " 0.489660 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 0.033415 | \n",
+ " 0.340433 | \n",
+ " 0.464971 | \n",
+ " 0.363737 | \n",
+ " 0.025815 | \n",
+ " 0.434129 | \n",
+ " 0.415163 | \n",
+ " 0.892210 | \n",
+ " 0.381701 | \n",
+ " 0.415264 | \n",
+ " 0.790801 | \n",
+ " 0.696930 | \n",
+ " 0.819751 | \n",
+ " 0.944029 | \n",
+ " 0.869965 | \n",
+ " 0.041723 | \n",
+ " 0.819140 | \n",
+ " 0.676051 | \n",
+ " 0.109349 | \n",
+ " 0.872947 | \n",
+ "
\n",
+ " \n",
+ " | 0 | \n",
+ " 0.276827 | \n",
+ " 0.260054 | \n",
+ " 0.942397 | \n",
+ " 0.113187 | \n",
+ " 0.781355 | \n",
+ " 0.475740 | \n",
+ " 0.152061 | \n",
+ " 0.250324 | \n",
+ " 0.147078 | \n",
+ " 0.162984 | \n",
+ " 0.977025 | \n",
+ " 0.509619 | \n",
+ " 0.593212 | \n",
+ " 0.911839 | \n",
+ " 0.257645 | \n",
+ " 0.386457 | \n",
+ " 0.696932 | \n",
+ " 0.069162 | \n",
+ " 0.952291 | \n",
+ " 0.286542 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 0.995885 | \n",
+ " 0.158381 | \n",
+ " 0.244274 | \n",
+ " 0.962163 | \n",
+ " 0.651900 | \n",
+ " 0.930665 | \n",
+ " 0.577190 | \n",
+ " 0.087914 | \n",
+ " 0.960261 | \n",
+ " 0.580840 | \n",
+ " 0.194616 | \n",
+ " 0.661459 | \n",
+ " 0.674085 | \n",
+ " 0.049326 | \n",
+ " 0.785803 | \n",
+ " 0.315645 | \n",
+ " 0.495355 | \n",
+ " 0.232135 | \n",
+ " 0.549324 | \n",
+ " 0.572232 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 0.641917 | \n",
+ " 0.821055 | \n",
+ " 0.392437 | \n",
+ " 0.782617 | \n",
+ " 0.510762 | \n",
+ " 0.428320 | \n",
+ " 0.017324 | \n",
+ " 0.680720 | \n",
+ " 0.340412 | \n",
+ " 0.462513 | \n",
+ " 0.785776 | \n",
+ " 0.251949 | \n",
+ " 0.032847 | \n",
+ " 0.995700 | \n",
+ " 0.816563 | \n",
+ " 0.735692 | \n",
+ " 0.435998 | \n",
+ " 0.430411 | \n",
+ " 0.531757 | \n",
+ " 0.489528 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 0.806532 | \n",
+ " 0.569258 | \n",
+ " 0.148175 | \n",
+ " 0.809987 | \n",
+ " 0.459632 | \n",
+ " 0.735762 | \n",
+ " 0.730664 | \n",
+ " 0.934502 | \n",
+ " 0.080322 | \n",
+ " 0.763502 | \n",
+ " 0.398504 | \n",
+ " 0.027637 | \n",
+ " 0.409665 | \n",
+ " 0.942846 | \n",
+ " 0.133256 | \n",
+ " 0.157158 | \n",
+ " 0.929446 | \n",
+ " 0.402791 | \n",
+ " 0.685976 | \n",
+ " 0.246594 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 0.311185 | \n",
+ " 0.501165 | \n",
+ " 0.365979 | \n",
+ " 0.782807 | \n",
+ " 0.776795 | \n",
+ " 0.797199 | \n",
+ " 0.791946 | \n",
+ " 0.847157 | \n",
+ " 0.771811 | \n",
+ " 0.233944 | \n",
+ " 0.522344 | \n",
+ " 0.053030 | \n",
+ " 0.208551 | \n",
+ " 0.824354 | \n",
+ " 0.588567 | \n",
+ " 0.604341 | \n",
+ " 0.232964 | \n",
+ " 0.229109 | \n",
+ " 0.022881 | \n",
+ " 0.479022 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 0 1 2 3 4 5 6 \\\n",
+ "0 0.734751 0.195362 0.734309 0.598184 0.763433 0.263434 0.868066 \n",
+ "1 0.772607 0.445391 0.249642 0.787922 0.598583 0.827238 0.624126 \n",
+ "2 0.226428 0.268764 0.694262 0.622335 0.063843 0.122683 0.815625 \n",
+ "3 0.362748 0.495430 0.113876 0.594149 0.612522 0.625204 0.864050 \n",
+ "4 0.033415 0.340433 0.464971 0.363737 0.025815 0.434129 0.415163 \n",
+ "0 0.276827 0.260054 0.942397 0.113187 0.781355 0.475740 0.152061 \n",
+ "1 0.995885 0.158381 0.244274 0.962163 0.651900 0.930665 0.577190 \n",
+ "2 0.641917 0.821055 0.392437 0.782617 0.510762 0.428320 0.017324 \n",
+ "3 0.806532 0.569258 0.148175 0.809987 0.459632 0.735762 0.730664 \n",
+ "4 0.311185 0.501165 0.365979 0.782807 0.776795 0.797199 0.791946 \n",
+ "\n",
+ " 7 8 9 10 11 12 13 \\\n",
+ "0 0.058092 0.753502 0.587513 0.311608 0.178356 0.182922 0.147631 \n",
+ "1 0.601524 0.688753 0.338870 0.081595 0.471474 0.267443 0.453351 \n",
+ "2 0.584542 0.032594 0.589775 0.764350 0.650973 0.565705 0.691784 \n",
+ "3 0.260279 0.528873 0.168043 0.715929 0.677014 0.175735 0.632370 \n",
+ "4 0.892210 0.381701 0.415264 0.790801 0.696930 0.819751 0.944029 \n",
+ "0 0.250324 0.147078 0.162984 0.977025 0.509619 0.593212 0.911839 \n",
+ "1 0.087914 0.960261 0.580840 0.194616 0.661459 0.674085 0.049326 \n",
+ "2 0.680720 0.340412 0.462513 0.785776 0.251949 0.032847 0.995700 \n",
+ "3 0.934502 0.080322 0.763502 0.398504 0.027637 0.409665 0.942846 \n",
+ "4 0.847157 0.771811 0.233944 0.522344 0.053030 0.208551 0.824354 \n",
+ "\n",
+ " 14 15 16 17 18 19 \n",
+ "0 0.391188 0.816049 0.749068 0.293260 0.937828 0.880858 \n",
+ "1 0.800716 0.045749 0.683793 0.389789 0.016787 0.503695 \n",
+ "2 0.265223 0.739031 0.560394 0.334802 0.517694 0.646110 \n",
+ "3 0.926715 0.085675 0.120525 0.141746 0.771144 0.489660 \n",
+ "4 0.869965 0.041723 0.819140 0.676051 0.109349 0.872947 \n",
+ "0 0.257645 0.386457 0.696932 0.069162 0.952291 0.286542 \n",
+ "1 0.785803 0.315645 0.495355 0.232135 0.549324 0.572232 \n",
+ "2 0.816563 0.735692 0.435998 0.430411 0.531757 0.489528 \n",
+ "3 0.133256 0.157158 0.929446 0.402791 0.685976 0.246594 \n",
+ "4 0.588567 0.604341 0.232964 0.229109 0.022881 0.479022 "
+ ]
+ },
+ "execution_count": 70,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df.head(10)"
+ ]
},
{
"cell_type": "markdown",
@@ -181,10 +583,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 81,
"metadata": {},
- "outputs": [],
- "source": []
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['2', '9', '12', '14', '17']\n"
+ ]
+ }
+ ],
+ "source": [
+ "print([x for x in df.columns if df[x].median()<0.48])"
+ ]
},
{
"cell_type": "markdown",
@@ -195,10 +607,356 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 83,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "df['20']=[x-0.1 for x in df['19']]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 84,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 2 | \n",
+ " 3 | \n",
+ " 4 | \n",
+ " 5 | \n",
+ " 6 | \n",
+ " 7 | \n",
+ " 8 | \n",
+ " 9 | \n",
+ " ... | \n",
+ " 11 | \n",
+ " 12 | \n",
+ " 13 | \n",
+ " 14 | \n",
+ " 15 | \n",
+ " 16 | \n",
+ " 17 | \n",
+ " 18 | \n",
+ " 19 | \n",
+ " 20 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 0.734751 | \n",
+ " 0.195362 | \n",
+ " 0.734309 | \n",
+ " 0.598184 | \n",
+ " 0.763433 | \n",
+ " 0.263434 | \n",
+ " 0.868066 | \n",
+ " 0.058092 | \n",
+ " 0.753502 | \n",
+ " 0.587513 | \n",
+ " ... | \n",
+ " 0.178356 | \n",
+ " 0.182922 | \n",
+ " 0.147631 | \n",
+ " 0.391188 | \n",
+ " 0.816049 | \n",
+ " 0.749068 | \n",
+ " 0.293260 | \n",
+ " 0.937828 | \n",
+ " 0.880858 | \n",
+ " 0.780858 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 0.772607 | \n",
+ " 0.445391 | \n",
+ " 0.249642 | \n",
+ " 0.787922 | \n",
+ " 0.598583 | \n",
+ " 0.827238 | \n",
+ " 0.624126 | \n",
+ " 0.601524 | \n",
+ " 0.688753 | \n",
+ " 0.338870 | \n",
+ " ... | \n",
+ " 0.471474 | \n",
+ " 0.267443 | \n",
+ " 0.453351 | \n",
+ " 0.800716 | \n",
+ " 0.045749 | \n",
+ " 0.683793 | \n",
+ " 0.389789 | \n",
+ " 0.016787 | \n",
+ " 0.503695 | \n",
+ " 0.403695 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 0.226428 | \n",
+ " 0.268764 | \n",
+ " 0.694262 | \n",
+ " 0.622335 | \n",
+ " 0.063843 | \n",
+ " 0.122683 | \n",
+ " 0.815625 | \n",
+ " 0.584542 | \n",
+ " 0.032594 | \n",
+ " 0.589775 | \n",
+ " ... | \n",
+ " 0.650973 | \n",
+ " 0.565705 | \n",
+ " 0.691784 | \n",
+ " 0.265223 | \n",
+ " 0.739031 | \n",
+ " 0.560394 | \n",
+ " 0.334802 | \n",
+ " 0.517694 | \n",
+ " 0.646110 | \n",
+ " 0.546110 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 0.362748 | \n",
+ " 0.495430 | \n",
+ " 0.113876 | \n",
+ " 0.594149 | \n",
+ " 0.612522 | \n",
+ " 0.625204 | \n",
+ " 0.864050 | \n",
+ " 0.260279 | \n",
+ " 0.528873 | \n",
+ " 0.168043 | \n",
+ " ... | \n",
+ " 0.677014 | \n",
+ " 0.175735 | \n",
+ " 0.632370 | \n",
+ " 0.926715 | \n",
+ " 0.085675 | \n",
+ " 0.120525 | \n",
+ " 0.141746 | \n",
+ " 0.771144 | \n",
+ " 0.489660 | \n",
+ " 0.389660 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 0.033415 | \n",
+ " 0.340433 | \n",
+ " 0.464971 | \n",
+ " 0.363737 | \n",
+ " 0.025815 | \n",
+ " 0.434129 | \n",
+ " 0.415163 | \n",
+ " 0.892210 | \n",
+ " 0.381701 | \n",
+ " 0.415264 | \n",
+ " ... | \n",
+ " 0.696930 | \n",
+ " 0.819751 | \n",
+ " 0.944029 | \n",
+ " 0.869965 | \n",
+ " 0.041723 | \n",
+ " 0.819140 | \n",
+ " 0.676051 | \n",
+ " 0.109349 | \n",
+ " 0.872947 | \n",
+ " 0.772947 | \n",
+ "
\n",
+ " \n",
+ " | 0 | \n",
+ " 0.276827 | \n",
+ " 0.260054 | \n",
+ " 0.942397 | \n",
+ " 0.113187 | \n",
+ " 0.781355 | \n",
+ " 0.475740 | \n",
+ " 0.152061 | \n",
+ " 0.250324 | \n",
+ " 0.147078 | \n",
+ " 0.162984 | \n",
+ " ... | \n",
+ " 0.509619 | \n",
+ " 0.593212 | \n",
+ " 0.911839 | \n",
+ " 0.257645 | \n",
+ " 0.386457 | \n",
+ " 0.696932 | \n",
+ " 0.069162 | \n",
+ " 0.952291 | \n",
+ " 0.286542 | \n",
+ " 0.186542 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 0.995885 | \n",
+ " 0.158381 | \n",
+ " 0.244274 | \n",
+ " 0.962163 | \n",
+ " 0.651900 | \n",
+ " 0.930665 | \n",
+ " 0.577190 | \n",
+ " 0.087914 | \n",
+ " 0.960261 | \n",
+ " 0.580840 | \n",
+ " ... | \n",
+ " 0.661459 | \n",
+ " 0.674085 | \n",
+ " 0.049326 | \n",
+ " 0.785803 | \n",
+ " 0.315645 | \n",
+ " 0.495355 | \n",
+ " 0.232135 | \n",
+ " 0.549324 | \n",
+ " 0.572232 | \n",
+ " 0.472232 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 0.641917 | \n",
+ " 0.821055 | \n",
+ " 0.392437 | \n",
+ " 0.782617 | \n",
+ " 0.510762 | \n",
+ " 0.428320 | \n",
+ " 0.017324 | \n",
+ " 0.680720 | \n",
+ " 0.340412 | \n",
+ " 0.462513 | \n",
+ " ... | \n",
+ " 0.251949 | \n",
+ " 0.032847 | \n",
+ " 0.995700 | \n",
+ " 0.816563 | \n",
+ " 0.735692 | \n",
+ " 0.435998 | \n",
+ " 0.430411 | \n",
+ " 0.531757 | \n",
+ " 0.489528 | \n",
+ " 0.389528 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 0.806532 | \n",
+ " 0.569258 | \n",
+ " 0.148175 | \n",
+ " 0.809987 | \n",
+ " 0.459632 | \n",
+ " 0.735762 | \n",
+ " 0.730664 | \n",
+ " 0.934502 | \n",
+ " 0.080322 | \n",
+ " 0.763502 | \n",
+ " ... | \n",
+ " 0.027637 | \n",
+ " 0.409665 | \n",
+ " 0.942846 | \n",
+ " 0.133256 | \n",
+ " 0.157158 | \n",
+ " 0.929446 | \n",
+ " 0.402791 | \n",
+ " 0.685976 | \n",
+ " 0.246594 | \n",
+ " 0.146594 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 0.311185 | \n",
+ " 0.501165 | \n",
+ " 0.365979 | \n",
+ " 0.782807 | \n",
+ " 0.776795 | \n",
+ " 0.797199 | \n",
+ " 0.791946 | \n",
+ " 0.847157 | \n",
+ " 0.771811 | \n",
+ " 0.233944 | \n",
+ " ... | \n",
+ " 0.053030 | \n",
+ " 0.208551 | \n",
+ " 0.824354 | \n",
+ " 0.588567 | \n",
+ " 0.604341 | \n",
+ " 0.232964 | \n",
+ " 0.229109 | \n",
+ " 0.022881 | \n",
+ " 0.479022 | \n",
+ " 0.379022 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
10 rows × 21 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " 0 1 2 3 4 5 6 \\\n",
+ "0 0.734751 0.195362 0.734309 0.598184 0.763433 0.263434 0.868066 \n",
+ "1 0.772607 0.445391 0.249642 0.787922 0.598583 0.827238 0.624126 \n",
+ "2 0.226428 0.268764 0.694262 0.622335 0.063843 0.122683 0.815625 \n",
+ "3 0.362748 0.495430 0.113876 0.594149 0.612522 0.625204 0.864050 \n",
+ "4 0.033415 0.340433 0.464971 0.363737 0.025815 0.434129 0.415163 \n",
+ "0 0.276827 0.260054 0.942397 0.113187 0.781355 0.475740 0.152061 \n",
+ "1 0.995885 0.158381 0.244274 0.962163 0.651900 0.930665 0.577190 \n",
+ "2 0.641917 0.821055 0.392437 0.782617 0.510762 0.428320 0.017324 \n",
+ "3 0.806532 0.569258 0.148175 0.809987 0.459632 0.735762 0.730664 \n",
+ "4 0.311185 0.501165 0.365979 0.782807 0.776795 0.797199 0.791946 \n",
+ "\n",
+ " 7 8 9 ... 11 12 13 14 \\\n",
+ "0 0.058092 0.753502 0.587513 ... 0.178356 0.182922 0.147631 0.391188 \n",
+ "1 0.601524 0.688753 0.338870 ... 0.471474 0.267443 0.453351 0.800716 \n",
+ "2 0.584542 0.032594 0.589775 ... 0.650973 0.565705 0.691784 0.265223 \n",
+ "3 0.260279 0.528873 0.168043 ... 0.677014 0.175735 0.632370 0.926715 \n",
+ "4 0.892210 0.381701 0.415264 ... 0.696930 0.819751 0.944029 0.869965 \n",
+ "0 0.250324 0.147078 0.162984 ... 0.509619 0.593212 0.911839 0.257645 \n",
+ "1 0.087914 0.960261 0.580840 ... 0.661459 0.674085 0.049326 0.785803 \n",
+ "2 0.680720 0.340412 0.462513 ... 0.251949 0.032847 0.995700 0.816563 \n",
+ "3 0.934502 0.080322 0.763502 ... 0.027637 0.409665 0.942846 0.133256 \n",
+ "4 0.847157 0.771811 0.233944 ... 0.053030 0.208551 0.824354 0.588567 \n",
+ "\n",
+ " 15 16 17 18 19 20 \n",
+ "0 0.816049 0.749068 0.293260 0.937828 0.880858 0.780858 \n",
+ "1 0.045749 0.683793 0.389789 0.016787 0.503695 0.403695 \n",
+ "2 0.739031 0.560394 0.334802 0.517694 0.646110 0.546110 \n",
+ "3 0.085675 0.120525 0.141746 0.771144 0.489660 0.389660 \n",
+ "4 0.041723 0.819140 0.676051 0.109349 0.872947 0.772947 \n",
+ "0 0.386457 0.696932 0.069162 0.952291 0.286542 0.186542 \n",
+ "1 0.315645 0.495355 0.232135 0.549324 0.572232 0.472232 \n",
+ "2 0.735692 0.435998 0.430411 0.531757 0.489528 0.389528 \n",
+ "3 0.157158 0.929446 0.402791 0.685976 0.246594 0.146594 \n",
+ "4 0.604341 0.232964 0.229109 0.022881 0.479022 0.379022 \n",
+ "\n",
+ "[10 rows x 21 columns]"
+ ]
+ },
+ "execution_count": 84,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "df.head(10)"
+ ]
},
{
"cell_type": "markdown",
@@ -209,10 +967,29 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 178,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "values_between=[df.iloc[i][x] for x in df for i in range(len(df[x])) if 0.7
Date: Sun, 29 Mar 2020 23:15:16 -0600
Subject: [PATCH 4/4] lab-string-operations
---
.../your-code/main.ipynb | 24 +--
.../your-code/challenge-1.ipynb | 170 +++++++++++++---
.../your-code/challenge-2.ipynb | 191 +++++++++++++++---
.../your-code/challenge-3.ipynb | 179 +++++++++++++++-
4 files changed, 498 insertions(+), 66 deletions(-)
diff --git a/module-1/lab-list-comprehensions/your-code/main.ipynb b/module-1/lab-list-comprehensions/your-code/main.ipynb
index 404314ad9..c9ea67ea2 100644
--- a/module-1/lab-list-comprehensions/your-code/main.ipynb
+++ b/module-1/lab-list-comprehensions/your-code/main.ipynb
@@ -53,7 +53,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
@@ -77,7 +77,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -95,7 +95,7 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 5,
"metadata": {},
"outputs": [
{
@@ -119,7 +119,7 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 6,
"metadata": {},
"outputs": [
{
@@ -143,7 +143,7 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -165,7 +165,7 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 8,
"metadata": {},
"outputs": [
{
@@ -189,7 +189,7 @@
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": 9,
"metadata": {},
"outputs": [
{
@@ -213,7 +213,7 @@
},
{
"cell_type": "code",
- "execution_count": 66,
+ "execution_count": 10,
"metadata": {},
"outputs": [
{
@@ -237,7 +237,7 @@
},
{
"cell_type": "code",
- "execution_count": 65,
+ "execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -246,7 +246,7 @@
},
{
"cell_type": "code",
- "execution_count": 70,
+ "execution_count": 14,
"metadata": {},
"outputs": [
{
@@ -565,7 +565,7 @@
"4 0.588567 0.604341 0.232964 0.229109 0.022881 0.479022 "
]
},
- "execution_count": 70,
+ "execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@@ -575,7 +575,7 @@
]
},
{
- "cell_type": "markdown",
+ "cell_type": "raw",
"metadata": {},
"source": [
"### 8. Use a list comprehension to select and print the column numbers for columns from the data set whose median is less than 0.48."
diff --git a/module-1/lab-string-operations/your-code/challenge-1.ipynb b/module-1/lab-string-operations/your-code/challenge-1.ipynb
index 43020841b..7654608c0 100644
--- a/module-1/lab-string-operations/your-code/challenge-1.ipynb
+++ b/module-1/lab-string-operations/your-code/challenge-1.ipynb
@@ -15,7 +15,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 148,
"metadata": {},
"outputs": [],
"source": [
@@ -33,12 +33,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 149,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Durante un tiempo no estuvo segura de si su marido era su marido.\n"
+ ]
+ }
+ ],
"source": [
"str_list = ['Durante', 'un', 'tiempo', 'no', 'estuvo', 'segura', 'de', 'si', 'su', 'marido', 'era', 'su', 'marido']\n",
- "# Your code here:\n"
+ "print(' '.join(str_list)+'.')"
]
},
{
@@ -50,12 +58,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 150,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Grocery list: Bananas, bread, Brownie Mix, broccoli.\n"
+ ]
+ }
+ ],
"source": [
"food_list = ['Bananas', 'Chocolate', 'bread', 'diapers', 'Ice Cream', 'Brownie Mix', 'broccoli']\n",
- "# Your code here:\n"
+ "print('Grocery list: '+', '.join([x for x in food_list if x.startswith('b') or x.startswith('B')])+'.')"
]
},
{
@@ -69,9 +85,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 151,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The area of the circle with radius: 4.50 is: 63.62\n"
+ ]
+ }
+ ],
"source": [
"import math\n",
"\n",
@@ -87,10 +111,10 @@
" # Sample input: 5.0\n",
" # Sample Output: 78.53981633\n",
" \n",
- " # Your code here:\n",
- " \n",
- " \n",
- "# Your output string here:"
+ " return pi*x**2\n",
+ "\n",
+ "# Your output string here:\n",
+ "print(string1, '{:.2f}'.format(radius), string2, '{:.2f}'.format(area(radius)))"
]
},
{
@@ -106,7 +130,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 192,
"metadata": {},
"outputs": [],
"source": [
@@ -119,8 +143,30 @@
"To say that for destruction ice\n",
"Is also great\n",
"And would suffice.\"\"\"\n",
- "\n",
- "# Your code here:\n"
+ "# We use replace if we want to count I’ve as two words(Erase # next line)\n",
+ "#poem=poem.replace('I’ve', 'I have')\n",
+ "poem_words=[x.strip('.'',''\\n').lower() for x in poem.split()]\n",
+ "# We used .lower to prevent 'To' and 'to' from generating 2 different keys since it is the same word\n",
+ "freq={}\n",
+ "for word in poem_words:\n",
+ " freq[word]=poem_words.count(word)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 193,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "{'some': 2, 'say': 3, 'the': 1, 'world': 1, 'will': 1, 'end': 1, 'in': 2, 'fire': 2, 'ice': 2, 'from': 1, 'what': 1, 'i’ve': 1, 'tasted': 1, 'of': 2, 'desire': 1, 'i': 3, 'hold': 1, 'with': 1, 'those': 1, 'who': 1, 'favor': 1, 'but': 1, 'if': 1, 'it': 1, 'had': 1, 'to': 2, 'perish': 1, 'twice': 1, 'think': 1, 'know': 1, 'enough': 1, 'hate': 1, 'that': 1, 'for': 1, 'destruction': 1, 'is': 1, 'also': 1, 'great': 1, 'and': 1, 'would': 1, 'suffice': 1}\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(freq)"
]
},
{
@@ -132,7 +178,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 194,
"metadata": {},
"outputs": [],
"source": [
@@ -158,7 +204,24 @@
"In the morning glad I see; \n",
"My foe outstretched beneath the tree.\"\"\"\n",
"\n",
- "# Your code here:\n"
+ "poem_whitelist=list(set([x.strip('.'',''\\n'';').lower() for x in poem.split() if x not in blacklist]))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 195,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['wiles', 'had', 'grow', 'with', 'friend', 'waterd', 'that', 'not', 'smiles', 'both', 'when', 'i', 'he', 'foe:', 'wrath', 'sunned', 'grew', 'outstretched', 'fears', 'garden', 'pole', 'till', 'shine', 'did', 'veild', 'beneath', 'stole', 'tree', 'angry', 'mine', 'told', 'bore', 'into', 'day', 'foe', 'tears:', 'was', 'glad', 'in', 'see', 'beheld', 'morning', 'my', 'bright', 'and', '&', 'end', 'soft', 'knew', 'deceitful', 'apple', 'night']\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(poem_whitelist)"
]
},
{
@@ -172,14 +235,31 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 196,
"metadata": {},
"outputs": [],
"source": [
"poem = \"\"\"The apparition of these faces in the crowd;\n",
"Petals on a wet, black bough.\"\"\"\n",
"\n",
- "# Your code here:\n"
+ "upper_char=[x for x in poem if x.isupper()]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 197,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['T', 'P']\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(upper_char)"
]
},
{
@@ -191,13 +271,30 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 198,
"metadata": {},
"outputs": [],
"source": [
"data = ['123abc', 'abc123', 'JohnSmith1', 'ABBY4', 'JANE']\n",
"\n",
- "# Your code here:\n"
+ "number_string=[x for x in data if re.search('\\d',x)]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 199,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['123abc', 'abc123', 'JohnSmith1', 'ABBY4']\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(number_string)"
]
},
{
@@ -213,12 +310,33 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 200,
"metadata": {},
"outputs": [],
"source": [
"data = ['123abc', 'abc123', 'JohnSmith1', 'ABBY4', 'JANE']\n",
- "# Your code here:\n"
+ "\n",
+ "low_number_string=[x for x in data if re.search('\\d'and'[a-z]',x)]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 201,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "['123abc', 'abc123', 'JohnSmith1']"
+ ]
+ },
+ "execution_count": 201,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "low_number_string"
]
}
],
@@ -238,9 +356,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.2"
+ "version": "3.7.3"
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/module-1/lab-string-operations/your-code/challenge-2.ipynb b/module-1/lab-string-operations/your-code/challenge-2.ipynb
index 87c5656ef..d84bc0fba 100644
--- a/module-1/lab-string-operations/your-code/challenge-2.ipynb
+++ b/module-1/lab-string-operations/your-code/challenge-2.ipynb
@@ -72,7 +72,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -88,13 +88,14 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
- "corpus = []\n",
- "\n",
- "# Write your code here\n"
+ "corpus=[]\n",
+ "for text in docs:\n",
+ " with open(text, \"r\") as f:\n",
+ " corpus.extend(f.readlines())"
]
},
{
@@ -106,9 +107,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['Ironhack is cool.', 'I love Ironhack.', 'I am a student at Ironhack.']\n"
+ ]
+ }
+ ],
"source": [
"print(corpus)"
]
@@ -136,11 +145,11 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
- "# Write your code here"
+ "corpus=[x.strip('.').lower() for x in corpus]"
]
},
{
@@ -152,7 +161,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -172,11 +181,14 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
- "# Write your code here"
+ "for string in corpus:\n",
+ " for word in string.split():\n",
+ " if word not in bag_of_words:\n",
+ " bag_of_words.append(word)"
]
},
{
@@ -192,9 +204,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['ironhack', 'is', 'cool', 'i', 'love', 'am', 'a', 'student', 'at']\n"
+ ]
+ }
+ ],
"source": [
"print(bag_of_words)"
]
@@ -208,13 +228,14 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"term_freq = []\n",
"\n",
- "# Write your code here"
+ "for string in corpus:\n",
+ " term_freq.append([string.split().count(word) for word in bag_of_words])"
]
},
{
@@ -228,9 +249,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[[1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 1, 0, 0, 0, 0], [1, 0, 0, 1, 0, 1, 1, 1, 1]]\n"
+ ]
+ }
+ ],
"source": [
"print(term_freq)"
]
@@ -278,13 +307,96 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "stop_words = ['all', 'six', 'less', 'being', 'indeed', 'over', 'move', 'anyway', 'fifty', 'four', 'not', 'own', 'through', 'yourselves', 'go', 'where', 'mill', 'only', 'find', 'before', 'one', 'whose', 'system', 'how', 'somewhere', 'with', 'thick', 'show', 'had', 'enough', 'should', 'to', 'must', 'whom', 'seeming', 'under', 'ours', 'has', 'might', 'thereafter', 'latterly', 'do', 'them', 'his', 'around', 'than', 'get', 'very', 'de', 'none', 'cannot', 'every', 'whether', 'they', 'front', 'during', 'thus', 'now', 'him', 'nor', 'name', 'several', 'hereafter', 'always', 'who', 'cry', 'whither', 'this', 'someone', 'either', 'each', 'become', 'thereupon', 'sometime', 'side', 'two', 'therein', 'twelve', 'because', 'often', 'ten', 'our', 'eg', 'some', 'back', 'up', 'namely', 'towards', 'are', 'further', 'beyond', 'ourselves', 'yet', 'out', 'even', 'will', 'what', 'still', 'for', 'bottom', 'mine', 'since', 'please', 'forty', 'per', 'its', 'everything', 'behind', 'un', 'above', 'between', 'it', 'neither', 'seemed', 'ever', 'across', 'she', 'somehow', 'be', 'we', 'full', 'never', 'sixty', 'however', 'here', 'otherwise', 'were', 'whereupon', 'nowhere', 'although', 'found', 'alone', 're', 'along', 'fifteen', 'by', 'both', 'about', 'last', 'would', 'anything', 'via', 'many', 'could', 'thence', 'put', 'against', 'keep', 'etc', 'amount', 'became', 'ltd', 'hence', 'onto', 'or', 'con', 'among', 'already', 'co', 'afterwards', 'formerly', 'within', 'seems', 'into', 'others', 'while', 'whatever', 'except', 'down', 'hers', 'everyone', 'done', 'least', 'another', 'whoever', 'moreover', 'couldnt', 'throughout', 'anyhow', 'yourself', 'three', 'from', 'her', 'few', 'together', 'top', 'there', 'due', 'been', 'next', 'anyone', 'eleven', 'much', 'call', 'therefore', 'interest', 'then', 'thru', 'themselves', 'hundred', 'was', 'sincere', 'empty', 'more', 'himself', 'elsewhere', 'mostly', 'on', 'fire', 'am', 'becoming', 'hereby', 'amongst', 'else', 'part', 'everywhere', 'too', 'herself', 'former', 'those', 'he', 'me', 'myself', 'made', 'twenty', 'these', 'bill', 'cant', 'us', 'until', 'besides', 'nevertheless', 'below', 'anywhere', 'nine', 'can', 'of', 'your', 'toward', 'my', 'something', 'and', 'whereafter', 'whenever', 'give', 'almost', 'wherever', 'is', 'describe', 'beforehand', 'herein', 'an', 'as', 'itself', 'at', 'have', 'in', 'seem', 'whence', 'ie', 'any', 'fill', 'again', 'hasnt', 'inc', 'thereby', 'thin', 'no', 'perhaps', 'latter', 'meanwhile', 'when', 'detail', 'same', 'wherein', 'beside', 'also', 'that', 'other', 'take', 'which', 'becomes', 'you', 'if', 'nobody', 'see', 'though', 'may', 'after', 'upon', 'most', 'hereupon', 'eight', 'but', 'serious', 'nothing', 'such', 'why', 'a', 'off', 'whereby', 'third', 'i', 'whole', 'noone', 'sometimes', 'well', 'amoungst', 'yours', 'their', 'rather', 'without', 'so', 'five', 'the', 'first', 'whereas', 'once']"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "bag_of_words=[x for x in bag_of_words if x not in stop_words]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
- "stop_words = ['all', 'six', 'less', 'being', 'indeed', 'over', 'move', 'anyway', 'fifty', 'four', 'not', 'own', 'through', 'yourselves', 'go', 'where', 'mill', 'only', 'find', 'before', 'one', 'whose', 'system', 'how', 'somewhere', 'with', 'thick', 'show', 'had', 'enough', 'should', 'to', 'must', 'whom', 'seeming', 'under', 'ours', 'has', 'might', 'thereafter', 'latterly', 'do', 'them', 'his', 'around', 'than', 'get', 'very', 'de', 'none', 'cannot', 'every', 'whether', 'they', 'front', 'during', 'thus', 'now', 'him', 'nor', 'name', 'several', 'hereafter', 'always', 'who', 'cry', 'whither', 'this', 'someone', 'either', 'each', 'become', 'thereupon', 'sometime', 'side', 'two', 'therein', 'twelve', 'because', 'often', 'ten', 'our', 'eg', 'some', 'back', 'up', 'namely', 'towards', 'are', 'further', 'beyond', 'ourselves', 'yet', 'out', 'even', 'will', 'what', 'still', 'for', 'bottom', 'mine', 'since', 'please', 'forty', 'per', 'its', 'everything', 'behind', 'un', 'above', 'between', 'it', 'neither', 'seemed', 'ever', 'across', 'she', 'somehow', 'be', 'we', 'full', 'never', 'sixty', 'however', 'here', 'otherwise', 'were', 'whereupon', 'nowhere', 'although', 'found', 'alone', 're', 'along', 'fifteen', 'by', 'both', 'about', 'last', 'would', 'anything', 'via', 'many', 'could', 'thence', 'put', 'against', 'keep', 'etc', 'amount', 'became', 'ltd', 'hence', 'onto', 'or', 'con', 'among', 'already', 'co', 'afterwards', 'formerly', 'within', 'seems', 'into', 'others', 'while', 'whatever', 'except', 'down', 'hers', 'everyone', 'done', 'least', 'another', 'whoever', 'moreover', 'couldnt', 'throughout', 'anyhow', 'yourself', 'three', 'from', 'her', 'few', 'together', 'top', 'there', 'due', 'been', 'next', 'anyone', 'eleven', 'much', 'call', 'therefore', 'interest', 'then', 'thru', 'themselves', 'hundred', 'was', 'sincere', 'empty', 'more', 'himself', 'elsewhere', 'mostly', 'on', 'fire', 'am', 'becoming', 'hereby', 'amongst', 'else', 'part', 'everywhere', 'too', 'herself', 'former', 'those', 'he', 'me', 'myself', 'made', 'twenty', 'these', 'bill', 'cant', 'us', 'until', 'besides', 'nevertheless', 'below', 'anywhere', 'nine', 'can', 'of', 'your', 'toward', 'my', 'something', 'and', 'whereafter', 'whenever', 'give', 'almost', 'wherever', 'is', 'describe', 'beforehand', 'herein', 'an', 'as', 'itself', 'at', 'have', 'in', 'seem', 'whence', 'ie', 'any', 'fill', 'again', 'hasnt', 'inc', 'thereby', 'thin', 'no', 'perhaps', 'latter', 'meanwhile', 'when', 'detail', 'same', 'wherein', 'beside', 'also', 'that', 'other', 'take', 'which', 'becomes', 'you', 'if', 'nobody', 'see', 'though', 'may', 'after', 'upon', 'most', 'hereupon', 'eight', 'but', 'serious', 'nothing', 'such', 'why', 'a', 'off', 'whereby', 'third', 'i', 'whole', 'noone', 'sometimes', 'well', 'amoungst', 'yours', 'their', 'rather', 'without', 'so', 'five', 'the', 'first', 'whereas', 'once']\n",
+ "term_freq = []\n",
"\n",
- "# Write your code below\n"
+ "for string in corpus:\n",
+ " term_freq.append([string.split().count(word) for word in bag_of_words])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['ironhack', 'cool', 'love', 'student']\n",
+ "[[1, 1, 0, 0], [1, 0, 1, 0], [1, 0, 0, 1]]\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(bag_of_words)\n",
+ "print(term_freq)\n",
+ "# It is different from expected because is,am,at are in stop_words list"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Output described before requirements (sorted)\n",
+ "#bag_of_words=[]\n",
+ "#for string in corpus:\n",
+ "# for word in string.split():\n",
+ "# if word not in bag_of_words:\n",
+ "# bag_of_words.append(word)\n",
+ "#fake_stop_words=['i','a']\n",
+ "#bag_of_words=sorted([x for x in bag_of_words if x not in fake_stop_words])\n",
+ "#term_freq = []\n",
+ "#\n",
+ "#for string in corpus:\n",
+ "# term_freq.append([string.split().count(word) for word in bag_of_words])\n",
+ "#print(bag_of_words)\n",
+ "#print(term_freq)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Output described after requirements\n",
+ "#bag_of_words=[]\n",
+ "#for string in corpus:\n",
+ "# for word in string.split():\n",
+ "# if word not in bag_of_words:\n",
+ "# bag_of_words.append(word)\n",
+ "#fake_stop_words=['i','a']\n",
+ "#bag_of_words=[x for x in bag_of_words if x not in fake_stop_words]\n",
+ "#term_freq = []\n",
+ "#\n",
+ "#for string in corpus:\n",
+ "# term_freq.append([string.split().count(word) for word in bag_of_words])\n",
+ "#print(bag_of_words)\n",
+ "#print(term_freq)"
]
},
{
@@ -315,6 +427,39 @@
" [1 1 0 1 0 0 1]]\n",
" ```"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from sklearn.feature_extraction.text import CountVectorizer\n",
+ "vectorizer = CountVectorizer()\n",
+ "X = vectorizer.fit_transform(corpus)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "{'ironhack': 3, 'is': 4, 'cool': 2, 'love': 5, 'am': 0, 'student': 6, 'at': 1}\n",
+ "[[0 0 1 1 1 0 0]\n",
+ " [0 0 0 1 0 1 0]\n",
+ " [1 1 0 1 0 0 1]]\n"
+ ]
+ }
+ ],
+ "source": [
+ "# It's the same as the one obtained with fake_stop_words list (sorted)\n",
+ "print(vectorizer.vocabulary_)\n",
+ "print(X.toarray())"
+ ]
}
],
"metadata": {
@@ -333,9 +478,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.2"
+ "version": "3.7.3"
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/module-1/lab-tuple-set-dict/your-code/challenge-3.ipynb b/module-1/lab-tuple-set-dict/your-code/challenge-3.ipynb
index 7ab8ea5d6..8f256c5ef 100644
--- a/module-1/lab-tuple-set-dict/your-code/challenge-3.ipynb
+++ b/module-1/lab-tuple-set-dict/your-code/challenge-3.ipynb
@@ -15,7 +15,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -49,11 +49,180 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
- "# Your code here\n"
+ "# Your code here\n",
+ "keys=word_freq.keys()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "word_freq=(sorted(word_freq.keys()),word_freq)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "['a',\n",
+ " 'about',\n",
+ " 'all',\n",
+ " 'although',\n",
+ " 'and',\n",
+ " 'are',\n",
+ " 'at',\n",
+ " 'baby',\n",
+ " 'backseat',\n",
+ " 'bag',\n",
+ " 'bar',\n",
+ " 'be',\n",
+ " 'bedsheets',\n",
+ " 'begin',\n",
+ " 'best',\n",
+ " 'body',\n",
+ " 'boy',\n",
+ " 'brand',\n",
+ " 'can',\n",
+ " 'chance',\n",
+ " 'club',\n",
+ " 'come',\n",
+ " 'conversation',\n",
+ " 'crazy',\n",
+ " 'dance',\n",
+ " 'date',\n",
+ " 'day',\n",
+ " 'discovering',\n",
+ " 'do',\n",
+ " 'doing',\n",
+ " \"don't\",\n",
+ " 'drinking',\n",
+ " 'driver',\n",
+ " 'eat',\n",
+ " 'every',\n",
+ " 'falling',\n",
+ " 'family',\n",
+ " 'fast',\n",
+ " 'fill',\n",
+ " 'find',\n",
+ " 'first',\n",
+ " 'follow',\n",
+ " 'for',\n",
+ " 'friends',\n",
+ " 'get',\n",
+ " 'girl',\n",
+ " 'give',\n",
+ " 'go',\n",
+ " 'going',\n",
+ " 'grab',\n",
+ " 'hand',\n",
+ " 'handmade',\n",
+ " 'heart',\n",
+ " 'hours',\n",
+ " 'how',\n",
+ " 'i',\n",
+ " \"i'll\",\n",
+ " \"i'm\",\n",
+ " 'in',\n",
+ " 'is',\n",
+ " \"isn't\",\n",
+ " 'it',\n",
+ " 'jukebox',\n",
+ " 'just',\n",
+ " 'kiss',\n",
+ " 'know',\n",
+ " 'last',\n",
+ " 'lead',\n",
+ " 'leave',\n",
+ " 'let',\n",
+ " \"let's\",\n",
+ " 'like',\n",
+ " 'love',\n",
+ " 'lover',\n",
+ " 'magnet',\n",
+ " 'make',\n",
+ " 'man',\n",
+ " 'may',\n",
+ " 'me',\n",
+ " 'mind',\n",
+ " 'much',\n",
+ " 'my',\n",
+ " 'new',\n",
+ " 'night',\n",
+ " 'not',\n",
+ " 'now',\n",
+ " 'of',\n",
+ " 'okay',\n",
+ " 'on',\n",
+ " 'one',\n",
+ " 'our',\n",
+ " 'out',\n",
+ " 'over',\n",
+ " 'place',\n",
+ " 'plate',\n",
+ " 'play',\n",
+ " 'pull',\n",
+ " 'push',\n",
+ " 'put',\n",
+ " 'radio',\n",
+ " 'room',\n",
+ " 'say',\n",
+ " 'shape',\n",
+ " 'shots',\n",
+ " 'singing',\n",
+ " 'slow',\n",
+ " 'smell',\n",
+ " 'so',\n",
+ " 'somebody',\n",
+ " 'something',\n",
+ " 'sour',\n",
+ " 'start',\n",
+ " 'stop',\n",
+ " 'story',\n",
+ " 'sweet',\n",
+ " 'table',\n",
+ " 'take',\n",
+ " 'talk',\n",
+ " 'taxi',\n",
+ " 'tell',\n",
+ " 'that',\n",
+ " 'the',\n",
+ " 'then',\n",
+ " 'thrifty',\n",
+ " 'to',\n",
+ " 'too',\n",
+ " 'trust',\n",
+ " 'up',\n",
+ " 'van',\n",
+ " 'waist',\n",
+ " 'want',\n",
+ " 'was',\n",
+ " 'we',\n",
+ " \"we're\",\n",
+ " 'week',\n",
+ " 'were',\n",
+ " 'where',\n",
+ " 'with',\n",
+ " 'you',\n",
+ " 'your']"
+ ]
+ },
+ "execution_count": 18,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "word_freq"
]
},
{
@@ -190,9 +359,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.2"
+ "version": "3.7.3"
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}