diff --git a/lab-list-comprehensions/your-code/main.ipynb b/lab-list-comprehensions/your-code/main.ipynb index c5931c4..34d8199 100644 --- a/lab-list-comprehensions/your-code/main.ipynb +++ b/lab-list-comprehensions/your-code/main.ipynb @@ -11,13 +11,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 85, "metadata": {}, "outputs": [], "source": [ "import os\n", "import numpy as np\n", - "import pandas as pd" + "import pandas as pd\n", + "from operator import itemgetter\n", + "import os\n", + "import glob" ] }, { @@ -29,10 +32,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "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": [ + "consecutive_integers = list(map(lambda x:x,range(1,51)))\n", + "print(consecutive_integers)" + ] }, { "cell_type": "markdown", @@ -43,10 +55,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "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": [ + "even_numbers = list(map(lambda x:x*2,range(1,101)))\n", + "print(even_numbers)" + ] }, { "cell_type": "markdown", @@ -57,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -75,10 +96,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": "[[0.84062117, 0.48006452, 0.7876326, 0.77109654],\n [0.44409793, 0.09014516, 0.81835917, 0.87645456],\n [0.7066597, 0.09610873, 0.41247947, 0.57433389],\n [0.29960807, 0.42315023, 0.34452557, 0.4751035],\n [0.17003563, 0.46843998, 0.92796258, 0.69814654],\n [0.41290051, 0.19561071, 0.16284783, 0.97016248],\n [0.71725408, 0.87702738, 0.31244595, 0.76615487],\n [0.20754036, 0.57871812, 0.07214068, 0.40356048],\n [0.12149553, 0.53222417, 0.9976855, 0.12536346],\n [0.80930099, 0.50962849, 0.94555126, 0.33364763]]" + }, + "metadata": {}, + "execution_count": 29 + } + ], + "source": [ + "a.tolist()" + ] }, { "cell_type": "markdown", @@ -89,10 +121,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": "array([0.84062117, 0.7876326 , 0.77109654, 0.81835917, 0.87645456,\n 0.7066597 , 0.57433389, 0.92796258, 0.69814654, 0.97016248,\n 0.71725408, 0.87702738, 0.76615487, 0.57871812, 0.53222417,\n 0.9976855 , 0.80930099, 0.50962849, 0.94555126])" + }, + "metadata": {}, + "execution_count": 28 + } + ], + "source": [ + "a[a>=0.5]\n", + " " + ] }, { "cell_type": "markdown", @@ -103,7 +147,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 53, "metadata": {}, "outputs": [], "source": [ @@ -125,10 +169,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 58, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "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": [ + "b_list = b.tolist()\n", + "print(b_list)" + ] }, { "cell_type": "markdown", @@ -139,10 +192,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 79, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": "[0.06833034, 0.10708681, 0.23760688]\n" + } + ], + "source": [ + "def Extract(b): \n", + " return [item[1][-1] for item in b]\n", + "\n", + "list_value = list(Extract(b))\n", + "last_value = []\n", + "\n", + "for i in list_value:\n", + " if i <= 0.5:\n", + " last_value.append(i)\n", + "print(last_value)" + ] }, { "cell_type": "markdown", @@ -153,10 +223,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 83, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": "['sample_file_1.csv', 'sample_file_0.csv', 'sample_file_2.csv', 'sample_file_3.csv', 'sample_file_7.csv', 'sample_file_6.csv', 'sample_file_4.csv', 'sample_file_5.csv', 'sample_file_8.csv', 'sample_file_9.csv']\n" + } + ], + "source": [ + "files = [f for f in os.listdir('/Users/alejandropalacios/Desktop/Ironhack/Data Analytics Bootcamp/Labs/Lab-list-comprehension/Lab-list-comprehension/lab-list-comprehensions/data') if f.endswith('.csv')]\n", + "\n", + "print(files)" + ] }, { "cell_type": "markdown", @@ -167,10 +247,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 93, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": " 0 1 2 3 4 5 6 \\\n0 0.215190 0.155352 0.160848 0.807736 0.363587 0.899832 0.146754 \n1 0.895544 0.955196 0.089925 0.827555 0.089071 0.642883 0.996052 \n2 0.413752 0.693052 0.789796 0.929164 0.536191 0.439769 0.773474 \n3 0.728001 0.348156 0.935787 0.851163 0.444573 0.715080 0.988408 \n4 0.134942 0.875931 0.273505 0.207588 0.080696 0.717396 0.033930 \n\n 7 8 9 10 11 12 13 \\\n0 0.094802 0.705133 0.882762 0.773320 0.687745 0.016789 0.340725 \n1 0.879020 0.421837 0.412141 0.858513 0.217091 0.176157 0.551236 \n2 0.982074 0.876955 0.633154 0.279005 0.483317 0.908288 0.756172 \n3 0.210332 0.732133 0.892383 0.216893 0.367595 0.846208 0.240111 \n4 0.646837 0.888722 0.922742 0.176593 0.861333 0.389451 0.695244 \n\n 14 15 16 17 18 19 \n0 0.984182 0.985461 0.412044 0.867894 0.113432 0.349845 \n1 0.834378 0.419535 0.041431 0.602258 0.984628 0.516899 \n2 0.462130 0.289892 0.145233 0.076819 0.797836 0.197592 \n3 0.471880 0.399721 0.758196 0.665568 0.931542 0.448124 \n4 0.129955 0.364114 0.428224 0.365442 0.847818 0.588319 ", + "text/html": "
| \n | 0 | \n1 | \n2 | \n3 | \n4 | \n5 | \n6 | \n7 | \n8 | \n9 | \n10 | \n11 | \n12 | \n13 | \n14 | \n15 | \n16 | \n17 | \n18 | \n19 | \n
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n0.215190 | \n0.155352 | \n0.160848 | \n0.807736 | \n0.363587 | \n0.899832 | \n0.146754 | \n0.094802 | \n0.705133 | \n0.882762 | \n0.773320 | \n0.687745 | \n0.016789 | \n0.340725 | \n0.984182 | \n0.985461 | \n0.412044 | \n0.867894 | \n0.113432 | \n0.349845 | \n
| 1 | \n0.895544 | \n0.955196 | \n0.089925 | \n0.827555 | \n0.089071 | \n0.642883 | \n0.996052 | \n0.879020 | \n0.421837 | \n0.412141 | \n0.858513 | \n0.217091 | \n0.176157 | \n0.551236 | \n0.834378 | \n0.419535 | \n0.041431 | \n0.602258 | \n0.984628 | \n0.516899 | \n
| 2 | \n0.413752 | \n0.693052 | \n0.789796 | \n0.929164 | \n0.536191 | \n0.439769 | \n0.773474 | \n0.982074 | \n0.876955 | \n0.633154 | \n0.279005 | \n0.483317 | \n0.908288 | \n0.756172 | \n0.462130 | \n0.289892 | \n0.145233 | \n0.076819 | \n0.797836 | \n0.197592 | \n
| 3 | \n0.728001 | \n0.348156 | \n0.935787 | \n0.851163 | \n0.444573 | \n0.715080 | \n0.988408 | \n0.210332 | \n0.732133 | \n0.892383 | \n0.216893 | \n0.367595 | \n0.846208 | \n0.240111 | \n0.471880 | \n0.399721 | \n0.758196 | \n0.665568 | \n0.931542 | \n0.448124 | \n
| 4 | \n0.134942 | \n0.875931 | \n0.273505 | \n0.207588 | \n0.080696 | \n0.717396 | \n0.033930 | \n0.646837 | \n0.888722 | \n0.922742 | \n0.176593 | \n0.861333 | \n0.389451 | \n0.695244 | \n0.129955 | \n0.364114 | \n0.428224 | \n0.365442 | \n0.847818 | \n0.588319 | \n