diff --git a/lab-list-comprehensions/your-code/.ipynb_checkpoints/main-checkpoint.ipynb b/lab-list-comprehensions/your-code/.ipynb_checkpoints/main-checkpoint.ipynb index 9860215..ef984e0 100644 --- a/lab-list-comprehensions/your-code/.ipynb_checkpoints/main-checkpoint.ipynb +++ b/lab-list-comprehensions/your-code/.ipynb_checkpoints/main-checkpoint.ipynb @@ -29,10 +29,21 @@ }, { "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": [ + "lista1 = [i for i in range(1,51) ]\n", + "print(lista1)" + ] }, { "cell_type": "markdown", @@ -43,10 +54,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "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": [ + "lista2 = [i for i in range(2,201,2) ]\n", + "print(lista2)" + ] }, { "cell_type": "markdown", @@ -75,10 +97,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "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": [ + "import numpy as np\n", + "import itertools\n", + "a = np.array([[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]])\n", + "\n", + "l = a.tolist()\n", + "\n", + " \n", + "c = [elemento for sublista in l for elemento in sublista]\n", + "print(c)\n", + "\n" + ] }, { "cell_type": "markdown", @@ -89,10 +139,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "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": [ + "d = [elemento for sublista in l for elemento in sublista if elemento >= 0.5]\n", + "\n", + "print(d)" + ] }, { "cell_type": "markdown", @@ -125,10 +187,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 38, "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": [ + "b = np.array([[[0.55867166, 0.06210792, 0.08147297],\n", + " [0.82579068, 0.91512478, 0.06833034]],\n", + "\n", + " [[0.05440634, 0.65857693, 0.30296619],\n", + " [0.06769833, 0.96031863, 0.51293743]],\n", + "\n", + " [[0.09143215, 0.71893382, 0.45850679],\n", + " [0.58256464, 0.59005654, 0.56266457]],\n", + "\n", + " [[0.71600294, 0.87392666, 0.11434044],\n", + " [0.8694668 , 0.65669313, 0.10708681]],\n", + "\n", + " [[0.07529684, 0.46470767, 0.47984544],\n", + " [0.65368638, 0.14901286, 0.23760688]]])\n", + "\n", + "q = b.tolist()\n", + "d = [y for sublista in q for elemento in sublista for y in elemento]\n", + "print(d)" + ] }, { "cell_type": "markdown", @@ -139,10 +228,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763]\n" + ] + } + ], + "source": [ + "f = [elemento for sublista in d if elemento <= 0.5]\n", + "print(f)" + ] }, { "cell_type": "markdown", @@ -153,10 +253,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['../data/sample_file_0.csv', '../data/sample_file_1.csv', '../data/sample_file_2.csv', '../data/sample_file_3.csv', '../data/sample_file_4.csv', '../data/sample_file_5.csv', '../data/sample_file_6.csv', '../data/sample_file_7.csv', '../data/sample_file_8.csv', '../data/sample_file_9.csv']\n" + ] + } + ], + "source": [ + "import os\n", + "\n", + "\n", + "a = [f'../data/{file}' for file in os.listdir('../data') if file.endswith('.csv')]\n", + "v = [f'Lab-list-comprehension / lab-list-comprehension / data{file}' for file in os.listdir('../data') if file.endswith('.csv')]\n", + "print(a)" + ] }, { "cell_type": "markdown", @@ -167,10 +282,179 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " 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", + "0 0.948664 0.215285 0.918270 0.599951 0.755120 0.971609 0.103190 \n", + "1 0.163236 0.803926 0.916655 0.775234 0.644890 0.701362 0.910208 \n", + "2 0.934136 0.031410 0.954057 0.853387 0.642160 0.681184 0.317198 \n", + "3 0.757038 0.918964 0.475459 0.837686 0.149645 0.819032 0.611996 \n", + "4 0.263455 0.816283 0.336707 0.587997 0.285871 0.619942 0.018027 \n", + "0 0.376101 0.896590 0.500995 0.381416 0.447730 0.048472 0.094235 \n", + "1 0.498192 0.565500 0.152394 0.284232 0.557042 0.417095 0.663465 \n", + "2 0.635284 0.247512 0.179986 0.468231 0.911799 0.764209 0.941413 \n", + "3 0.647497 0.072412 0.681403 0.977189 0.690953 0.829347 0.236915 \n", + "4 0.170792 0.586900 0.029834 0.921923 0.090727 0.592746 0.972429 \n", + "0 0.901381 0.790944 0.596603 0.354721 0.357002 0.321325 0.738398 \n", + "1 0.763823 0.537281 0.708804 0.975269 0.053777 0.957740 0.389137 \n", + "2 0.571864 0.386243 0.567476 0.509283 0.552594 0.173807 0.229092 \n", + "3 0.956168 0.422274 0.121713 0.685208 0.713370 0.416245 0.337151 \n", + "4 0.121826 0.237479 0.553956 0.173660 0.354423 0.532080 0.271361 \n", + "0 0.437114 0.156941 0.183148 0.817785 0.747632 0.726855 0.944758 \n", + "1 0.213337 0.503490 0.802663 0.443484 0.700893 0.129329 0.007176 \n", + "2 0.625692 0.184609 0.120652 0.410955 0.408272 0.686792 0.480168 \n", + "3 0.642007 0.175592 0.476889 0.451096 0.803491 0.272613 0.576037 \n", + "4 0.809129 0.549374 0.055405 0.857802 0.760688 0.662257 0.453289 \n", + "0 0.702566 0.092336 0.245083 0.918402 0.695110 0.886921 0.588605 \n", + "1 0.177005 0.649551 0.467321 0.449597 0.458872 0.815586 0.455132 \n", + "2 0.689556 0.445586 0.005691 0.150171 0.554146 0.492320 0.185612 \n", + "3 0.047188 0.854596 0.833368 0.043878 0.883505 0.786302 0.980916 \n", + "4 0.936065 0.725831 0.184239 0.677391 0.242726 0.125457 0.356254 \n", + "0 0.460281 0.308551 0.735894 0.054059 0.593642 0.397679 0.019922 \n", + "1 0.065851 0.736029 0.797730 0.692722 0.167764 0.839756 0.910186 \n", + "2 0.671323 0.747296 0.892328 0.732902 0.065608 0.262364 0.712417 \n", + "3 0.445478 0.523522 0.959355 0.348292 0.761805 0.301391 0.712240 \n", + "4 0.291399 0.551248 0.736542 0.163562 0.451149 0.888938 0.968465 \n", + "0 0.132453 0.106635 0.673568 0.507253 0.162925 0.130042 0.980388 \n", + "1 0.384938 0.767604 0.850528 0.605998 0.826172 0.667488 0.142045 \n", + "2 0.318691 0.675720 0.807189 0.752518 0.531342 0.703225 0.598293 \n", + "3 0.538593 0.291241 0.407187 0.613260 0.851424 0.962086 0.590512 \n", + "4 0.713271 0.156210 0.392800 0.702348 0.009400 0.030304 0.960066 \n", + "0 0.215190 0.155352 0.160848 0.807736 0.363587 0.899832 0.146754 \n", + "1 0.895544 0.955196 0.089925 0.827555 0.089071 0.642883 0.996052 \n", + "2 0.413752 0.693052 0.789796 0.929164 0.536191 0.439769 0.773474 \n", + "3 0.728001 0.348156 0.935787 0.851163 0.444573 0.715080 0.988408 \n", + "4 0.134942 0.875931 0.273505 0.207588 0.080696 0.717396 0.033930 \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", + "0 0.194754 0.932388 0.591727 0.697517 0.607355 0.177649 0.435968 \n", + "1 0.871204 0.321745 0.586035 0.887054 0.240060 0.915342 0.205310 \n", + "2 0.875259 0.538416 0.867511 0.813309 0.215624 0.552062 0.498378 \n", + "3 0.644348 0.938444 0.410444 0.561513 0.499231 0.856437 0.054619 \n", + "4 0.548845 0.121471 0.194299 0.149844 0.848866 0.531840 0.663384 \n", + "0 0.986890 0.582352 0.037230 0.130306 0.766153 0.153783 0.199140 \n", + "1 0.158188 0.039182 0.543442 0.521210 0.993481 0.580359 0.765757 \n", + "2 0.808370 0.578024 0.181267 0.064788 0.924226 0.070744 0.704575 \n", + "3 0.406938 0.898234 0.513575 0.532473 0.790312 0.082292 0.850821 \n", + "4 0.774760 0.293800 0.956949 0.811740 0.525562 0.454788 0.848812 \n", + "0 0.777885 0.775623 0.717817 0.788198 0.962214 0.394465 0.878922 \n", + "1 0.689829 0.510885 0.737445 0.097678 0.242906 0.073603 0.497591 \n", + "2 0.257945 0.313437 0.418311 0.750007 0.604759 0.234886 0.832337 \n", + "3 0.570693 0.435938 0.360098 0.037437 0.167545 0.847880 0.773456 \n", + "4 0.766006 0.607020 0.197302 0.526352 0.676571 0.473574 0.953228 \n", + "0 0.287449 0.792692 0.080025 0.079886 0.067887 0.543498 0.711158 \n", + "1 0.027735 0.427692 0.156926 0.486138 0.571278 0.940414 0.940730 \n", + "2 0.286901 0.320112 0.048815 0.768725 0.461014 0.090451 0.720938 \n", + "3 0.774269 0.323313 0.349850 0.413465 0.641111 0.841210 0.668661 \n", + "4 0.658329 0.973615 0.449771 0.615229 0.467290 0.158077 0.305716 \n", + "0 0.950970 0.168079 0.783107 0.698836 0.120857 0.207432 0.824789 \n", + "1 0.729812 0.998528 0.048724 0.377391 0.729498 0.721515 0.566724 \n", + "2 0.060855 0.457443 0.847337 0.603072 0.346574 0.898464 0.482963 \n", + "3 0.004030 0.619601 0.547769 0.160962 0.545281 0.931623 0.991855 \n", + "4 0.937350 0.215774 0.212762 0.483018 0.573162 0.634487 0.423924 \n", + "0 0.855673 0.339445 0.895810 0.832431 0.553308 0.617711 0.841575 \n", + "1 0.643328 0.371559 0.674311 0.424815 0.279397 0.015081 0.788497 \n", + "2 0.764379 0.017461 0.131970 0.649451 0.902157 0.034188 0.840938 \n", + "3 0.945462 0.139241 0.105477 0.889501 0.160828 0.400774 0.770295 \n", + "4 0.396090 0.681679 0.390542 0.030394 0.944077 0.366139 0.078188 \n", + "0 0.623167 0.074066 0.111557 0.864664 0.093637 0.446974 0.022525 \n", + "1 0.086904 0.912348 0.892183 0.426389 0.776552 0.429496 0.602056 \n", + "2 0.921508 0.563333 0.184300 0.667625 0.270017 0.573440 0.163669 \n", + "3 0.980700 0.159022 0.684265 0.898633 0.470113 0.756593 0.282408 \n", + "4 0.688937 0.260252 0.634608 0.273775 0.264145 0.682941 0.908499 \n", + "0 0.094802 0.705133 0.882762 0.773320 0.687745 0.016789 0.340725 \n", + "1 0.879020 0.421837 0.412141 0.858513 0.217091 0.176157 0.551236 \n", + "2 0.982074 0.876955 0.633154 0.279005 0.483317 0.908288 0.756172 \n", + "3 0.210332 0.732133 0.892383 0.216893 0.367595 0.846208 0.240111 \n", + "4 0.646837 0.888722 0.922742 0.176593 0.861333 0.389451 0.695244 \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 \n", + "0 0.202404 0.979777 0.095713 0.159040 0.651457 0.803393 \n", + "1 0.489504 0.848926 0.304342 0.358977 0.841539 0.964889 \n", + "2 0.739656 0.307914 0.233996 0.602166 0.244210 0.313071 \n", + "3 0.326310 0.461825 0.954783 0.361873 0.145952 0.873029 \n", + "4 0.084884 0.120312 0.463214 0.437889 0.542376 0.668447 \n", + "0 0.330318 0.969657 0.110998 0.033474 0.117277 0.213938 \n", + "1 0.931264 0.336841 0.271230 0.509798 0.877048 0.310951 \n", + "2 0.948127 0.971452 0.360861 0.074394 0.386949 0.396453 \n", + "3 0.088025 0.289218 0.822775 0.515933 0.962827 0.026952 \n", + "4 0.095214 0.415311 0.026496 0.513342 0.830389 0.931145 \n", + "0 0.084206 0.680941 0.992897 0.267455 0.212403 0.572150 \n", + "1 0.798467 0.789078 0.947559 0.631497 0.057953 0.060306 \n", + "2 0.421263 0.455785 0.893841 0.726412 0.458360 0.048740 \n", + "3 0.490628 0.544232 0.954668 0.567280 0.571539 0.560742 \n", + "4 0.413186 0.957242 0.642558 0.351496 0.547297 0.177401 \n", + "0 0.960030 0.810807 0.579395 0.660811 0.520295 0.945250 \n", + "1 0.933377 0.427869 0.654402 0.407580 0.122453 0.115311 \n", + "2 0.192501 0.219077 0.034113 0.858956 0.816036 0.582192 \n", + "3 0.101031 0.972135 0.479581 0.149982 0.035150 0.528075 \n", + "4 0.730355 0.412336 0.469142 0.078734 0.448741 0.827487 \n", + "0 0.349212 0.818606 0.376941 0.886644 0.472826 0.551858 \n", + "1 0.338366 0.877239 0.129824 0.773155 0.485385 0.686294 \n", + "2 0.443979 0.430132 0.713078 0.302786 0.051382 0.203699 \n", + "3 0.821099 0.654592 0.346710 0.183948 0.372739 0.739383 \n", + "4 0.394633 0.766967 0.606719 0.538712 0.885516 0.667051 \n", + "0 0.336094 0.951907 0.050986 0.856135 0.773953 0.295344 \n", + "1 0.132391 0.766033 0.708510 0.752866 0.493862 0.577262 \n", + "2 0.098536 0.957824 0.566209 0.655947 0.592733 0.002596 \n", + "3 0.844655 0.772798 0.584262 0.807400 0.177419 0.926007 \n", + "4 0.175482 0.232489 0.806964 0.904593 0.803629 0.792851 \n", + "0 0.713369 0.707874 0.563506 0.982256 0.562498 0.968681 \n", + "1 0.283769 0.166793 0.316878 0.688337 0.169525 0.966198 \n", + "2 0.032852 0.689315 0.973684 0.719610 0.163670 0.724486 \n", + "3 0.551369 0.732153 0.494100 0.792803 0.794426 0.837695 \n", + "4 0.450950 0.200761 0.968324 0.221165 0.891382 0.398914 \n", + "0 0.984182 0.985461 0.412044 0.867894 0.113432 0.349845 \n", + "1 0.834378 0.419535 0.041431 0.602258 0.984628 0.516899 \n", + "2 0.462130 0.289892 0.145233 0.076819 0.797836 0.197592 \n", + "3 0.471880 0.399721 0.758196 0.665568 0.931542 0.448124 \n", + "4 0.129955 0.364114 0.428224 0.365442 0.847818 0.588319 \n" + ] + } + ], + "source": [ + "import pandas as pd\n", + "\n", + "df = [pd.read_csv(dato) for dato in a]\n", + "final = pd.concat(df)\n", + "\n", + "print(final)\n" + ] }, { "cell_type": "markdown", @@ -181,10 +465,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['2', '9', '12', '14', '17']\n" + ] + } + ], + "source": [ + "listax = [i for i in final if final[i].median() < 0.48 ]\n", + "print(listax)" + ] }, { "cell_type": "markdown", @@ -195,10 +490,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 61, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "expression cannot contain assignment, perhaps you meant \"==\"? (3547912624.py, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Input \u001b[1;32mIn [61]\u001b[1;36m\u001b[0m\n\u001b[1;33m data.assing(20 = lambda x: x.'19' - 0,1)\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m expression cannot contain assignment, perhaps you meant \"==\"?\n" + ] + } + ], + "source": [ + "data.assing(veinte = lambda x: x.19 - 0,1)\n", + "\n", + "#sorry estas dos, intente de todo, espero verlas el sabado que viene para aprender :)" + ] }, { "cell_type": "markdown", @@ -207,6 +515,31 @@ "### 10. Use a list comprehension to extract and print all values from the data set that are between 0.7 and 0.75." ] }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'Series' object has no attribute 'value'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", + "Input \u001b[1;32mIn [62]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m listan \u001b[38;5;241m=\u001b[39m listax \u001b[38;5;241m=\u001b[39m [i \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m final \u001b[38;5;28;01mif\u001b[39;00m final[i]\u001b[38;5;241m.\u001b[39mvalue() \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m0.48\u001b[39m ]\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(listan)\n", + "Input \u001b[1;32mIn [62]\u001b[0m, in \u001b[0;36m\u001b[1;34m(.0)\u001b[0m\n\u001b[1;32m----> 1\u001b[0m listan \u001b[38;5;241m=\u001b[39m listax \u001b[38;5;241m=\u001b[39m [i \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m final \u001b[38;5;28;01mif\u001b[39;00m \u001b[43mfinal\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvalue\u001b[49m() \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m0.48\u001b[39m ]\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(listan)\n", + "File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\pandas\\core\\generic.py:5575\u001b[0m, in \u001b[0;36mNDFrame.__getattr__\u001b[1;34m(self, name)\u001b[0m\n\u001b[0;32m 5568\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\n\u001b[0;32m 5569\u001b[0m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_internal_names_set\n\u001b[0;32m 5570\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_metadata\n\u001b[0;32m 5571\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_accessors\n\u001b[0;32m 5572\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_info_axis\u001b[38;5;241m.\u001b[39m_can_hold_identifiers_and_holds_name(name)\n\u001b[0;32m 5573\u001b[0m ):\n\u001b[0;32m 5574\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m[name]\n\u001b[1;32m-> 5575\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mobject\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__getattribute__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[1;31mAttributeError\u001b[0m: 'Series' object has no attribute 'value'" + ] + } + ], + "source": [ + "listan = listax = [i for i in final if final[i].value() < 0.48 ]\n", + "\n", + "print(listan)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -217,7 +550,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -231,9 +564,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.7" + "version": "3.9.12" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/lab-list-comprehensions/your-code/main.ipynb b/lab-list-comprehensions/your-code/main.ipynb index 9860215..ef984e0 100644 --- a/lab-list-comprehensions/your-code/main.ipynb +++ b/lab-list-comprehensions/your-code/main.ipynb @@ -29,10 +29,21 @@ }, { "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": [ + "lista1 = [i for i in range(1,51) ]\n", + "print(lista1)" + ] }, { "cell_type": "markdown", @@ -43,10 +54,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "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": [ + "lista2 = [i for i in range(2,201,2) ]\n", + "print(lista2)" + ] }, { "cell_type": "markdown", @@ -75,10 +97,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "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": [ + "import numpy as np\n", + "import itertools\n", + "a = np.array([[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]])\n", + "\n", + "l = a.tolist()\n", + "\n", + " \n", + "c = [elemento for sublista in l for elemento in sublista]\n", + "print(c)\n", + "\n" + ] }, { "cell_type": "markdown", @@ -89,10 +139,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "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": [ + "d = [elemento for sublista in l for elemento in sublista if elemento >= 0.5]\n", + "\n", + "print(d)" + ] }, { "cell_type": "markdown", @@ -125,10 +187,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 38, "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": [ + "b = np.array([[[0.55867166, 0.06210792, 0.08147297],\n", + " [0.82579068, 0.91512478, 0.06833034]],\n", + "\n", + " [[0.05440634, 0.65857693, 0.30296619],\n", + " [0.06769833, 0.96031863, 0.51293743]],\n", + "\n", + " [[0.09143215, 0.71893382, 0.45850679],\n", + " [0.58256464, 0.59005654, 0.56266457]],\n", + "\n", + " [[0.71600294, 0.87392666, 0.11434044],\n", + " [0.8694668 , 0.65669313, 0.10708681]],\n", + "\n", + " [[0.07529684, 0.46470767, 0.47984544],\n", + " [0.65368638, 0.14901286, 0.23760688]]])\n", + "\n", + "q = b.tolist()\n", + "d = [y for sublista in q for elemento in sublista for y in elemento]\n", + "print(d)" + ] }, { "cell_type": "markdown", @@ -139,10 +228,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763, 0.33364763]\n" + ] + } + ], + "source": [ + "f = [elemento for sublista in d if elemento <= 0.5]\n", + "print(f)" + ] }, { "cell_type": "markdown", @@ -153,10 +253,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['../data/sample_file_0.csv', '../data/sample_file_1.csv', '../data/sample_file_2.csv', '../data/sample_file_3.csv', '../data/sample_file_4.csv', '../data/sample_file_5.csv', '../data/sample_file_6.csv', '../data/sample_file_7.csv', '../data/sample_file_8.csv', '../data/sample_file_9.csv']\n" + ] + } + ], + "source": [ + "import os\n", + "\n", + "\n", + "a = [f'../data/{file}' for file in os.listdir('../data') if file.endswith('.csv')]\n", + "v = [f'Lab-list-comprehension / lab-list-comprehension / data{file}' for file in os.listdir('../data') if file.endswith('.csv')]\n", + "print(a)" + ] }, { "cell_type": "markdown", @@ -167,10 +282,179 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " 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", + "0 0.948664 0.215285 0.918270 0.599951 0.755120 0.971609 0.103190 \n", + "1 0.163236 0.803926 0.916655 0.775234 0.644890 0.701362 0.910208 \n", + "2 0.934136 0.031410 0.954057 0.853387 0.642160 0.681184 0.317198 \n", + "3 0.757038 0.918964 0.475459 0.837686 0.149645 0.819032 0.611996 \n", + "4 0.263455 0.816283 0.336707 0.587997 0.285871 0.619942 0.018027 \n", + "0 0.376101 0.896590 0.500995 0.381416 0.447730 0.048472 0.094235 \n", + "1 0.498192 0.565500 0.152394 0.284232 0.557042 0.417095 0.663465 \n", + "2 0.635284 0.247512 0.179986 0.468231 0.911799 0.764209 0.941413 \n", + "3 0.647497 0.072412 0.681403 0.977189 0.690953 0.829347 0.236915 \n", + "4 0.170792 0.586900 0.029834 0.921923 0.090727 0.592746 0.972429 \n", + "0 0.901381 0.790944 0.596603 0.354721 0.357002 0.321325 0.738398 \n", + "1 0.763823 0.537281 0.708804 0.975269 0.053777 0.957740 0.389137 \n", + "2 0.571864 0.386243 0.567476 0.509283 0.552594 0.173807 0.229092 \n", + "3 0.956168 0.422274 0.121713 0.685208 0.713370 0.416245 0.337151 \n", + "4 0.121826 0.237479 0.553956 0.173660 0.354423 0.532080 0.271361 \n", + "0 0.437114 0.156941 0.183148 0.817785 0.747632 0.726855 0.944758 \n", + "1 0.213337 0.503490 0.802663 0.443484 0.700893 0.129329 0.007176 \n", + "2 0.625692 0.184609 0.120652 0.410955 0.408272 0.686792 0.480168 \n", + "3 0.642007 0.175592 0.476889 0.451096 0.803491 0.272613 0.576037 \n", + "4 0.809129 0.549374 0.055405 0.857802 0.760688 0.662257 0.453289 \n", + "0 0.702566 0.092336 0.245083 0.918402 0.695110 0.886921 0.588605 \n", + "1 0.177005 0.649551 0.467321 0.449597 0.458872 0.815586 0.455132 \n", + "2 0.689556 0.445586 0.005691 0.150171 0.554146 0.492320 0.185612 \n", + "3 0.047188 0.854596 0.833368 0.043878 0.883505 0.786302 0.980916 \n", + "4 0.936065 0.725831 0.184239 0.677391 0.242726 0.125457 0.356254 \n", + "0 0.460281 0.308551 0.735894 0.054059 0.593642 0.397679 0.019922 \n", + "1 0.065851 0.736029 0.797730 0.692722 0.167764 0.839756 0.910186 \n", + "2 0.671323 0.747296 0.892328 0.732902 0.065608 0.262364 0.712417 \n", + "3 0.445478 0.523522 0.959355 0.348292 0.761805 0.301391 0.712240 \n", + "4 0.291399 0.551248 0.736542 0.163562 0.451149 0.888938 0.968465 \n", + "0 0.132453 0.106635 0.673568 0.507253 0.162925 0.130042 0.980388 \n", + "1 0.384938 0.767604 0.850528 0.605998 0.826172 0.667488 0.142045 \n", + "2 0.318691 0.675720 0.807189 0.752518 0.531342 0.703225 0.598293 \n", + "3 0.538593 0.291241 0.407187 0.613260 0.851424 0.962086 0.590512 \n", + "4 0.713271 0.156210 0.392800 0.702348 0.009400 0.030304 0.960066 \n", + "0 0.215190 0.155352 0.160848 0.807736 0.363587 0.899832 0.146754 \n", + "1 0.895544 0.955196 0.089925 0.827555 0.089071 0.642883 0.996052 \n", + "2 0.413752 0.693052 0.789796 0.929164 0.536191 0.439769 0.773474 \n", + "3 0.728001 0.348156 0.935787 0.851163 0.444573 0.715080 0.988408 \n", + "4 0.134942 0.875931 0.273505 0.207588 0.080696 0.717396 0.033930 \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", + "0 0.194754 0.932388 0.591727 0.697517 0.607355 0.177649 0.435968 \n", + "1 0.871204 0.321745 0.586035 0.887054 0.240060 0.915342 0.205310 \n", + "2 0.875259 0.538416 0.867511 0.813309 0.215624 0.552062 0.498378 \n", + "3 0.644348 0.938444 0.410444 0.561513 0.499231 0.856437 0.054619 \n", + "4 0.548845 0.121471 0.194299 0.149844 0.848866 0.531840 0.663384 \n", + "0 0.986890 0.582352 0.037230 0.130306 0.766153 0.153783 0.199140 \n", + "1 0.158188 0.039182 0.543442 0.521210 0.993481 0.580359 0.765757 \n", + "2 0.808370 0.578024 0.181267 0.064788 0.924226 0.070744 0.704575 \n", + "3 0.406938 0.898234 0.513575 0.532473 0.790312 0.082292 0.850821 \n", + "4 0.774760 0.293800 0.956949 0.811740 0.525562 0.454788 0.848812 \n", + "0 0.777885 0.775623 0.717817 0.788198 0.962214 0.394465 0.878922 \n", + "1 0.689829 0.510885 0.737445 0.097678 0.242906 0.073603 0.497591 \n", + "2 0.257945 0.313437 0.418311 0.750007 0.604759 0.234886 0.832337 \n", + "3 0.570693 0.435938 0.360098 0.037437 0.167545 0.847880 0.773456 \n", + "4 0.766006 0.607020 0.197302 0.526352 0.676571 0.473574 0.953228 \n", + "0 0.287449 0.792692 0.080025 0.079886 0.067887 0.543498 0.711158 \n", + "1 0.027735 0.427692 0.156926 0.486138 0.571278 0.940414 0.940730 \n", + "2 0.286901 0.320112 0.048815 0.768725 0.461014 0.090451 0.720938 \n", + "3 0.774269 0.323313 0.349850 0.413465 0.641111 0.841210 0.668661 \n", + "4 0.658329 0.973615 0.449771 0.615229 0.467290 0.158077 0.305716 \n", + "0 0.950970 0.168079 0.783107 0.698836 0.120857 0.207432 0.824789 \n", + "1 0.729812 0.998528 0.048724 0.377391 0.729498 0.721515 0.566724 \n", + "2 0.060855 0.457443 0.847337 0.603072 0.346574 0.898464 0.482963 \n", + "3 0.004030 0.619601 0.547769 0.160962 0.545281 0.931623 0.991855 \n", + "4 0.937350 0.215774 0.212762 0.483018 0.573162 0.634487 0.423924 \n", + "0 0.855673 0.339445 0.895810 0.832431 0.553308 0.617711 0.841575 \n", + "1 0.643328 0.371559 0.674311 0.424815 0.279397 0.015081 0.788497 \n", + "2 0.764379 0.017461 0.131970 0.649451 0.902157 0.034188 0.840938 \n", + "3 0.945462 0.139241 0.105477 0.889501 0.160828 0.400774 0.770295 \n", + "4 0.396090 0.681679 0.390542 0.030394 0.944077 0.366139 0.078188 \n", + "0 0.623167 0.074066 0.111557 0.864664 0.093637 0.446974 0.022525 \n", + "1 0.086904 0.912348 0.892183 0.426389 0.776552 0.429496 0.602056 \n", + "2 0.921508 0.563333 0.184300 0.667625 0.270017 0.573440 0.163669 \n", + "3 0.980700 0.159022 0.684265 0.898633 0.470113 0.756593 0.282408 \n", + "4 0.688937 0.260252 0.634608 0.273775 0.264145 0.682941 0.908499 \n", + "0 0.094802 0.705133 0.882762 0.773320 0.687745 0.016789 0.340725 \n", + "1 0.879020 0.421837 0.412141 0.858513 0.217091 0.176157 0.551236 \n", + "2 0.982074 0.876955 0.633154 0.279005 0.483317 0.908288 0.756172 \n", + "3 0.210332 0.732133 0.892383 0.216893 0.367595 0.846208 0.240111 \n", + "4 0.646837 0.888722 0.922742 0.176593 0.861333 0.389451 0.695244 \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 \n", + "0 0.202404 0.979777 0.095713 0.159040 0.651457 0.803393 \n", + "1 0.489504 0.848926 0.304342 0.358977 0.841539 0.964889 \n", + "2 0.739656 0.307914 0.233996 0.602166 0.244210 0.313071 \n", + "3 0.326310 0.461825 0.954783 0.361873 0.145952 0.873029 \n", + "4 0.084884 0.120312 0.463214 0.437889 0.542376 0.668447 \n", + "0 0.330318 0.969657 0.110998 0.033474 0.117277 0.213938 \n", + "1 0.931264 0.336841 0.271230 0.509798 0.877048 0.310951 \n", + "2 0.948127 0.971452 0.360861 0.074394 0.386949 0.396453 \n", + "3 0.088025 0.289218 0.822775 0.515933 0.962827 0.026952 \n", + "4 0.095214 0.415311 0.026496 0.513342 0.830389 0.931145 \n", + "0 0.084206 0.680941 0.992897 0.267455 0.212403 0.572150 \n", + "1 0.798467 0.789078 0.947559 0.631497 0.057953 0.060306 \n", + "2 0.421263 0.455785 0.893841 0.726412 0.458360 0.048740 \n", + "3 0.490628 0.544232 0.954668 0.567280 0.571539 0.560742 \n", + "4 0.413186 0.957242 0.642558 0.351496 0.547297 0.177401 \n", + "0 0.960030 0.810807 0.579395 0.660811 0.520295 0.945250 \n", + "1 0.933377 0.427869 0.654402 0.407580 0.122453 0.115311 \n", + "2 0.192501 0.219077 0.034113 0.858956 0.816036 0.582192 \n", + "3 0.101031 0.972135 0.479581 0.149982 0.035150 0.528075 \n", + "4 0.730355 0.412336 0.469142 0.078734 0.448741 0.827487 \n", + "0 0.349212 0.818606 0.376941 0.886644 0.472826 0.551858 \n", + "1 0.338366 0.877239 0.129824 0.773155 0.485385 0.686294 \n", + "2 0.443979 0.430132 0.713078 0.302786 0.051382 0.203699 \n", + "3 0.821099 0.654592 0.346710 0.183948 0.372739 0.739383 \n", + "4 0.394633 0.766967 0.606719 0.538712 0.885516 0.667051 \n", + "0 0.336094 0.951907 0.050986 0.856135 0.773953 0.295344 \n", + "1 0.132391 0.766033 0.708510 0.752866 0.493862 0.577262 \n", + "2 0.098536 0.957824 0.566209 0.655947 0.592733 0.002596 \n", + "3 0.844655 0.772798 0.584262 0.807400 0.177419 0.926007 \n", + "4 0.175482 0.232489 0.806964 0.904593 0.803629 0.792851 \n", + "0 0.713369 0.707874 0.563506 0.982256 0.562498 0.968681 \n", + "1 0.283769 0.166793 0.316878 0.688337 0.169525 0.966198 \n", + "2 0.032852 0.689315 0.973684 0.719610 0.163670 0.724486 \n", + "3 0.551369 0.732153 0.494100 0.792803 0.794426 0.837695 \n", + "4 0.450950 0.200761 0.968324 0.221165 0.891382 0.398914 \n", + "0 0.984182 0.985461 0.412044 0.867894 0.113432 0.349845 \n", + "1 0.834378 0.419535 0.041431 0.602258 0.984628 0.516899 \n", + "2 0.462130 0.289892 0.145233 0.076819 0.797836 0.197592 \n", + "3 0.471880 0.399721 0.758196 0.665568 0.931542 0.448124 \n", + "4 0.129955 0.364114 0.428224 0.365442 0.847818 0.588319 \n" + ] + } + ], + "source": [ + "import pandas as pd\n", + "\n", + "df = [pd.read_csv(dato) for dato in a]\n", + "final = pd.concat(df)\n", + "\n", + "print(final)\n" + ] }, { "cell_type": "markdown", @@ -181,10 +465,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['2', '9', '12', '14', '17']\n" + ] + } + ], + "source": [ + "listax = [i for i in final if final[i].median() < 0.48 ]\n", + "print(listax)" + ] }, { "cell_type": "markdown", @@ -195,10 +490,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 61, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "expression cannot contain assignment, perhaps you meant \"==\"? (3547912624.py, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m Input \u001b[1;32mIn [61]\u001b[1;36m\u001b[0m\n\u001b[1;33m data.assing(20 = lambda x: x.'19' - 0,1)\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m expression cannot contain assignment, perhaps you meant \"==\"?\n" + ] + } + ], + "source": [ + "data.assing(veinte = lambda x: x.19 - 0,1)\n", + "\n", + "#sorry estas dos, intente de todo, espero verlas el sabado que viene para aprender :)" + ] }, { "cell_type": "markdown", @@ -207,6 +515,31 @@ "### 10. Use a list comprehension to extract and print all values from the data set that are between 0.7 and 0.75." ] }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'Series' object has no attribute 'value'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", + "Input \u001b[1;32mIn [62]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m listan \u001b[38;5;241m=\u001b[39m listax \u001b[38;5;241m=\u001b[39m [i \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m final \u001b[38;5;28;01mif\u001b[39;00m final[i]\u001b[38;5;241m.\u001b[39mvalue() \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m0.48\u001b[39m ]\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(listan)\n", + "Input \u001b[1;32mIn [62]\u001b[0m, in \u001b[0;36m\u001b[1;34m(.0)\u001b[0m\n\u001b[1;32m----> 1\u001b[0m listan \u001b[38;5;241m=\u001b[39m listax \u001b[38;5;241m=\u001b[39m [i \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m final \u001b[38;5;28;01mif\u001b[39;00m \u001b[43mfinal\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvalue\u001b[49m() \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m0.48\u001b[39m ]\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(listan)\n", + "File \u001b[1;32m~\\anaconda3\\lib\\site-packages\\pandas\\core\\generic.py:5575\u001b[0m, in \u001b[0;36mNDFrame.__getattr__\u001b[1;34m(self, name)\u001b[0m\n\u001b[0;32m 5568\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\n\u001b[0;32m 5569\u001b[0m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_internal_names_set\n\u001b[0;32m 5570\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_metadata\n\u001b[0;32m 5571\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_accessors\n\u001b[0;32m 5572\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_info_axis\u001b[38;5;241m.\u001b[39m_can_hold_identifiers_and_holds_name(name)\n\u001b[0;32m 5573\u001b[0m ):\n\u001b[0;32m 5574\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m[name]\n\u001b[1;32m-> 5575\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mobject\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__getattribute__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[1;31mAttributeError\u001b[0m: 'Series' object has no attribute 'value'" + ] + } + ], + "source": [ + "listan = listax = [i for i in final if final[i].value() < 0.48 ]\n", + "\n", + "print(listan)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -217,7 +550,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -231,9 +564,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.7" + "version": "3.9.12" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }