diff --git a/M2/Machine Learning/TP_1/2025_TP_1_M2_ISF.ipynb b/M2/Machine Learning/TP_1/2025_TP_1_M2_ISF.ipynb index 94de13d..e1ebbae 100644 --- a/M2/Machine Learning/TP_1/2025_TP_1_M2_ISF.ipynb +++ b/M2/Machine Learning/TP_1/2025_TP_1_M2_ISF.ipynb @@ -42,7 +42,7 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 2, "id": "e5631491", "metadata": {}, "outputs": [ @@ -71,7 +71,7 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 3, "id": "b8acd836", "metadata": {}, "outputs": [ @@ -107,7 +107,7 @@ }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 4, "id": "acc09d5e", "metadata": {}, "outputs": [ @@ -130,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 5, "id": "8590bf3a", "metadata": {}, "outputs": [ @@ -149,7 +149,7 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 6, "id": "20165055", "metadata": {}, "outputs": [ @@ -159,7 +159,7 @@ "4" ] }, - "execution_count": 68, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -178,7 +178,7 @@ }, { "cell_type": "code", - "execution_count": 69, + "execution_count": 7, "id": "4028380e", "metadata": {}, "outputs": [ @@ -205,7 +205,7 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 8, "id": "f2ab3b16", "metadata": {}, "outputs": [ @@ -237,7 +237,7 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 9, "id": "817fddfd", "metadata": {}, "outputs": [ @@ -292,7 +292,7 @@ }, { "cell_type": "code", - "execution_count": 72, + "execution_count": 10, "id": "98874653", "metadata": {}, "outputs": [ @@ -301,10 +301,10 @@ "output_type": "stream", "text": [ "[6, 7, 8]\n", - "159 ns ± 37 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)\n", + "142 ns ± 11.3 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)\n", "[24333339, 24333340, 24333341]\n", "[6, 7, 8]\n", - "81.5 ns ± 2.51 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)\n", + "83.2 ns ± 2.36 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)\n", "[3, 4, 5]\n", "0 3\n", "1 4\n", @@ -332,7 +332,7 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 11, "id": "fd4a92a4", "metadata": {}, "outputs": [ @@ -394,7 +394,7 @@ }, { "cell_type": "code", - "execution_count": 74, + "execution_count": 12, "id": "02221362", "metadata": {}, "outputs": [ @@ -464,7 +464,7 @@ }, { "cell_type": "code", - "execution_count": 75, + "execution_count": 13, "id": "dc035fc6", "metadata": {}, "outputs": [ @@ -536,7 +536,7 @@ }, { "cell_type": "code", - "execution_count": 76, + "execution_count": 14, "id": "fb8a02fc", "metadata": {}, "outputs": [ @@ -544,14 +544,14 @@ "name": "stdout", "output_type": "stream", "text": [ - "1 0.243129\n", - "2 0.120497\n", - "3 0.661678\n", - "5 0.431023\n", - "dtype: float64 1 -1.877149\n", - "2 1.084410\n", - "3 -1.401333\n", - "4 2.323768\n", + "1 -0.438450\n", + "2 -1.208483\n", + "3 0.448063\n", + "5 -0.262394\n", + "dtype: float64 1 0.841306\n", + "2 2.140871\n", + "3 -1.221346\n", + "4 0.352957\n", "dtype: float64\n" ] } @@ -576,7 +576,7 @@ }, { "cell_type": "code", - "execution_count": 77, + "execution_count": 15, "id": "c414f7ab", "metadata": {}, "outputs": [ @@ -585,11 +585,11 @@ "output_type": "stream", "text": [ " s t\n", - "1 0.243129 -1.877149\n", - "2 0.120497 1.084410\n", - "3 0.661678 -1.401333\n", - "4 NaN 2.323768\n", - "5 0.431023 NaN\n" + "1 -0.438450 0.841306\n", + "2 -1.208483 2.140871\n", + "3 0.448063 -1.221346\n", + "4 NaN 0.352957\n", + "5 -0.262394 NaN\n" ] } ], @@ -615,7 +615,7 @@ }, { "cell_type": "code", - "execution_count": 78, + "execution_count": 16, "id": "d385358c", "metadata": {}, "outputs": [ @@ -624,11 +624,11 @@ "output_type": "stream", "text": [ " s t SUM\n", - "1 0.243129 -1.877149 -1.634020\n", - "2 0.120497 1.084410 1.204908\n", - "3 0.661678 -1.401333 -0.739655\n", - "4 NaN 2.323768 NaN\n", - "5 0.431023 NaN NaN\n" + "1 -0.438450 0.841306 0.402856\n", + "2 -1.208483 2.140871 0.932388\n", + "3 0.448063 -1.221346 -0.773283\n", + "4 NaN 0.352957 NaN\n", + "5 -0.262394 NaN NaN\n" ] } ], @@ -649,7 +649,7 @@ }, { "cell_type": "code", - "execution_count": 79, + "execution_count": 17, "id": "004ea932", "metadata": {}, "outputs": [ @@ -657,7 +657,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "-0.389589093728373\n" + "0.18732051523044305\n" ] } ], @@ -698,7 +698,7 @@ }, { "cell_type": "code", - "execution_count": 80, + "execution_count": 18, "id": "90c3ce0c", "metadata": {}, "outputs": [ @@ -706,69 +706,48 @@ "name": "stdout", "output_type": "stream", "text": [ - "[ 5.49723823e-01 -1.31082378e+00 -6.22760329e-01 -2.62949717e-01\n", - " 4.57882668e-01 -1.59461170e+00 1.05538811e+00 -2.47209963e-01\n", - " 7.13256480e-01 1.44496096e+00 8.23773799e-01 -3.30667927e-01\n", - " -9.56503260e-02 7.45352858e-01 -4.32283190e-01 2.31530959e-01\n", - " 6.37509236e-01 2.31185634e-01 -1.20012729e+00 -2.35712669e-02\n", - " 3.17696113e-01 -2.88214765e+00 -1.23726528e+00 -6.97195930e-01\n", - " -4.87292472e-01 -1.01214626e+00 1.61589513e+00 3.37852380e-01\n", - " -1.74946052e-01 -1.20920617e+00 9.03870311e-02 -3.07258009e-01\n", - " -3.10397749e-01 -3.32008854e-01 -1.15886038e+00 2.12804614e-01\n", - " 2.60152242e-01 -1.29252004e+00 -3.33166985e+00 -4.69845591e-01\n", - " -2.25371388e+00 1.61491101e+00 -2.75463852e-01 3.88422564e-01\n", - " -1.02801527e-01 2.08622449e+00 -6.13437096e-01 1.41284922e-01\n", - " -7.78141741e-01 7.39777873e-01 -1.64159000e+00 1.24423378e+00\n", - " 7.48597865e-01 8.74895734e-01 -1.08514842e+00 1.12577205e+00\n", - " -2.57945739e-01 -6.90450632e-01 -5.69399190e-01 -2.31033310e-01\n", - " -4.83728490e-01 -2.14742654e-01 -7.51141688e-01 7.66933693e-01\n", - " -9.57226686e-01 -4.30699928e-01 2.28666912e-01 8.61871499e-01\n", - " 1.03068499e+00 2.17921640e+00 -6.02719103e-01 1.64892582e-01\n", - " -2.22512366e-01 -1.81064011e-01 -1.91618541e+00 -1.83873109e-01\n", - " -9.29893809e-01 -9.01671426e-01 8.35696189e-01 3.14861256e-01\n", - " 2.47187503e-01 1.53374094e+00 -3.14452903e+00 -1.55291714e+00\n", - " 7.88856808e-01 -1.82891453e+00 -1.66248048e+00 3.87953404e-01\n", - " 7.34848194e-01 5.66630707e-01 -1.91984446e+00 -7.94352703e-01\n", - " -1.07785703e+00 1.20883414e+00 -4.67383798e-01 2.53383618e+00\n", - " -1.37801661e+00 -1.91719281e-01 -8.07215757e-01 6.81252472e-01\n", - " -1.00333308e+00 1.20718757e+00 -1.65435057e+00 6.08411511e-01\n", - " 1.04282471e-01 -5.66180100e-01 -1.32743256e-01 -1.31161120e+00\n", - " 9.60961716e-01 -5.93451605e-01 2.69214343e-01 4.98934405e-01\n", - " -1.66050737e-01 -8.62418377e-02 -2.59329804e+00 3.62691383e-01\n", - " 1.56065069e+00 -1.19008019e+00 -4.12291407e-01 -5.65906249e-02\n", - " 1.07063941e+00 -1.55673086e+00 5.80081641e-01 -2.98945228e-01\n", - " 6.00838705e-01 -1.09766403e+00 1.46468310e+00 4.33030265e-02\n", - " 5.37300372e-02 5.69581246e-01 -8.38004229e-01 2.17191762e+00\n", - " 2.61695242e-01 -2.26121746e-01 1.76349971e-01 -2.99109244e-01\n", - " 8.55575563e-01 1.08929611e+00 -1.75560658e+00 -4.94108477e-01\n", - " -1.20773476e+00 5.99213072e-01 -4.70264655e-01 -2.83854681e+00\n", - " -6.67533402e-01 2.68384595e-03 -2.28505336e-01 -1.66896521e-01\n", - " 3.83767940e-01 -8.18634351e-01 -1.80681435e-02 1.95678277e+00\n", - " -3.19979705e-01 1.04908399e+00 -1.79325760e-01 1.05356993e+00\n", - " 8.44210718e-01 -1.13155820e-01 7.33324161e-02 -8.77563195e-02\n", - " -5.46247848e-01 -7.01349251e-01 -4.86817183e-01 -3.80312716e-01\n", - " 1.13385935e+00 -3.29551446e-01 4.75178143e-01 -3.99293756e-01\n", - " 3.21380689e+00 7.11493474e-01 -5.57452116e-01 -1.27923709e-01\n", - " -1.18060426e-01 -2.90118101e-01 2.55462698e+00 1.82784346e+00\n", - " 2.09441740e-01 -3.11607087e-01 1.58206957e+00 -1.03920923e+00\n", - " 1.58273642e-01 -3.87976151e-01 -2.41492247e-01 6.82781712e-01\n", - " -1.39314775e-01 1.69250146e+00 4.73171075e-01 1.23777781e+00\n", - " 1.94373099e-01 -1.31467157e+00 -4.95374012e-02 -6.35543779e-01\n", - " 1.43322926e-01 7.65554576e-01 5.25991389e-01 -1.14121490e+00\n", - " -1.59325886e+00 7.12285333e-01 1.77293192e-01 -2.01506883e+00\n", - " -9.80835679e-01 4.55426418e-01 -9.56967585e-01 -8.57511153e-01\n", - " -1.06710549e+00 -5.97830609e-01 1.33747103e+00 6.28934901e-03\n", - " 1.07189752e+00 1.59283006e-01 -3.69665818e-01 3.33204138e-01\n", - " 7.62345403e-01 5.40839445e-01 -1.11377123e-01 -4.57959689e-01\n", - " 1.56912841e+00 8.70473207e-01 -3.74765710e-01 6.87430409e-01\n", - " -4.74617018e-01 -1.57582446e+00 -8.34879110e-01 3.30927984e-01\n", - " 1.20415788e+00 7.19295702e-01 5.88584618e-01 -2.22883984e-01\n", - " -3.76034448e-01 3.77574960e-02 1.67710538e+00 -2.22784347e+00\n", - " 5.13524775e-01 -2.59294898e-02 -1.05789057e+00 -5.22341043e-01\n", - " -2.02132136e+00 -7.84539236e-01 -1.37535622e+00 4.25588428e-01\n", - " 5.09526701e-01 -7.74401045e-01 9.09169480e-01 -1.01978350e+00\n", - " -1.31227734e+00 -4.82121622e-01 4.06569462e-01 2.52543371e-01\n", - " 1.32871537e+00 2.67734602e-01]\n", + "[-0.28773909 -0.19608369 -1.71793628 0.4612952 0.5515725 1.04280641\n", + " 1.17184868 -0.13231035 -1.57743404 -1.7028202 0.50512756 -0.21103384\n", + " 0.50030009 -0.32068785 1.27479901 0.24010222 0.40215479 0.21052298\n", + " 0.79705954 0.99483457 0.87016811 -0.65045873 -0.4241659 -0.23120831\n", + " -0.08236706 -1.39387221 -1.6252061 -0.54322453 1.23794904 -0.10269127\n", + " -0.11368796 0.63437397 -1.26912704 -1.26881737 -1.33170357 0.10345176\n", + " -0.22823399 -1.00903668 1.56660454 0.74150993 -1.57404043 -0.6684005\n", + " 0.84852676 1.18689507 -0.57169764 1.59073219 -0.09800917 -1.90926036\n", + " -0.94731368 -0.6388644 -1.47222336 -1.06317011 -1.54369687 -0.10519326\n", + " 0.88091458 -1.97152905 0.10982669 -0.10946848 0.97146505 0.96993824\n", + " 1.10281044 -1.07066335 -1.47536973 0.56356437 1.71318051 1.05600855\n", + " -1.85053625 -0.52543189 -1.70081492 -0.04053544 0.29496354 -1.334264\n", + " -1.23186525 1.16096679 0.75676875 -1.2453203 -0.77572143 -1.09606885\n", + " 0.23276306 0.0282081 0.61687087 1.03423895 2.16853053 0.9211597\n", + " -0.19572309 -0.47576158 0.90264495 -0.31255346 -0.65092045 0.56926707\n", + " -1.19474236 0.03179875 0.45733006 2.83385064 0.16855239 -1.77871846\n", + " -1.07386222 -1.95054243 -0.91879528 -1.37625311 0.63007335 2.35855647\n", + " 0.84869766 1.00607664 0.93959402 -0.97095208 0.86285522 -0.89510269\n", + " 0.14714791 -1.87238007 -2.11558833 -0.45750744 2.26001524 1.18369865\n", + " -1.35324762 0.34743472 -0.58372574 -0.05690051 0.44855136 0.04982748\n", + " -0.4703972 -0.58881805 -0.36235875 -1.35660378 -1.57907595 -0.86967715\n", + " -1.77263259 -1.59092993 -0.53653465 -1.29665434 -1.85639913 -0.04776515\n", + " -0.19259513 0.47776231 0.37893506 0.65928439 -0.00563499 0.2370161\n", + " -0.4436264 1.56962832 1.58173496 0.69310857 1.22572239 0.69254197\n", + " 0.51639957 0.47305348 1.64532235 0.15873721 1.30740748 -1.10057541\n", + " -0.5307283 0.94672098 -0.46691422 0.79167021 0.36886743 -0.1483422\n", + " -0.67323767 0.95830864 1.35471767 -1.49798619 -0.3981345 -0.83316573\n", + " -0.75577251 -1.53244118 0.94092691 0.49673154 1.82678175 -0.22536834\n", + " -1.29154315 -1.12910549 -1.12919147 0.0750761 0.69788266 -1.76178555\n", + " 0.35116516 0.24299277 -1.06054169 -1.24700377 0.41474723 1.6696988\n", + " -0.14511423 -0.26102964 0.30783974 0.07101309 1.30799088 0.97982849\n", + " 1.16756744 0.19206422 0.06234357 0.76826103 -1.54204781 -0.53155133\n", + " -0.7707208 0.60626615 0.26458768 -1.09532669 2.4254157 0.15155951\n", + " 1.54560881 -0.256521 -0.51091719 -0.5056481 0.63730113 -0.39055129\n", + " 0.20751616 -0.08261539 -0.96998325 -0.701281 0.63161056 0.67499282\n", + " -0.25939738 2.22862077 1.44761861 -1.49093798 1.16590215 0.22558368\n", + " -0.03006352 -1.17256376 0.64468106 -0.57952401 -0.71238886 0.48092743\n", + " 0.82090768 0.02947906 0.42266537 -2.07191302 -0.31131951 -0.41263715\n", + " -1.72577159 0.90184042 0.04960449 0.35080306 1.38860793 -1.7273121\n", + " -1.41958804 2.05543272 -0.24095805 -2.71722213 0.40250332 -0.3776332\n", + " 1.2811601 -0.15254383 -0.21544241 1.85743455 2.36985563 -1.45811596\n", + " 2.15755815 0.08924284 -0.37378036 -0.35659756]\n", "250\n" ] } @@ -785,7 +764,7 @@ }, { "cell_type": "code", - "execution_count": 81, + "execution_count": 19, "id": "756550e8", "metadata": {}, "outputs": [ @@ -793,17 +772,17 @@ "name": "stdout", "output_type": "stream", "text": [ - "2012-01-01 0.549724\n", - "2012-01-02 -1.310824\n", - "2012-01-03 -0.622760\n", - "2012-01-04 -0.262950\n", - "2012-01-05 0.457883\n", + "2012-01-01 -0.287739\n", + "2012-01-02 -0.196084\n", + "2012-01-03 -1.717936\n", + "2012-01-04 0.461295\n", + "2012-01-05 0.551572\n", " ... \n", - "2012-09-02 -0.482122\n", - "2012-09-03 0.406569\n", - "2012-09-04 0.252543\n", - "2012-09-05 1.328715\n", - "2012-09-06 0.267735\n", + "2012-09-02 -1.458116\n", + "2012-09-03 2.157558\n", + "2012-09-04 0.089243\n", + "2012-09-05 -0.373780\n", + "2012-09-06 -0.356598\n", "Freq: D, Length: 250, dtype: float64\n" ] } @@ -817,7 +796,7 @@ }, { "cell_type": "code", - "execution_count": 82, + "execution_count": 20, "id": "91f53912", "metadata": {}, "outputs": [ @@ -867,7 +846,7 @@ }, { "cell_type": "code", - "execution_count": 83, + "execution_count": 21, "id": "97d58527", "metadata": {}, "outputs": [], @@ -891,7 +870,7 @@ }, { "cell_type": "code", - "execution_count": 84, + "execution_count": 22, "id": "c9597b48", "metadata": {}, "outputs": [], @@ -918,7 +897,7 @@ }, { "cell_type": "code", - "execution_count": 85, + "execution_count": 23, "id": "8051b5f4", "metadata": {}, "outputs": [], @@ -937,7 +916,7 @@ }, { "cell_type": "code", - "execution_count": 86, + "execution_count": 24, "id": "14b2a9c7", "metadata": {}, "outputs": [ @@ -1036,7 +1015,7 @@ "type": "float" } ], - "ref": "e6f40b4a-5d49-4980-809e-e8d5f3af0389", + "ref": "a994954a-8a4a-426c-9081-10156ac92c07", "rows": [ [ "0", @@ -1317,7 +1296,7 @@ "4 (66,74] [10000;15000[ 0 0.0 1.000000 " ] }, - "execution_count": 86, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -1329,7 +1308,7 @@ }, { "cell_type": "code", - "execution_count": 87, + "execution_count": 25, "id": "e85ee86b", "metadata": {}, "outputs": [ @@ -1428,7 +1407,7 @@ "type": "float" } ], - "ref": "c81a4158-60cd-44bd-b3c0-efedfd7c893d", + "ref": "3f9d9cab-f45b-4754-b84f-3970f98c3cc8", "rows": [ [ "14259", @@ -1716,7 +1695,7 @@ "14263 0.142466 " ] }, - "execution_count": 87, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -1728,7 +1707,7 @@ }, { "cell_type": "code", - "execution_count": 88, + "execution_count": 26, "id": "dbdd334a", "metadata": {}, "outputs": [ @@ -1827,7 +1806,7 @@ "type": "float" } ], - "ref": "896fad9f-a81f-4109-b48a-0e5b5d83b56a", + "ref": "5a0fe66e-6b0e-4348-b8f4-092da2d1592f", "rows": [ [ "count", @@ -2385,7 +2364,7 @@ "max 83421.850000 1.000000 " ] }, - "execution_count": 88, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -2397,7 +2376,7 @@ }, { "cell_type": "code", - "execution_count": 89, + "execution_count": 27, "id": "6a32bf11", "metadata": {}, "outputs": [ @@ -2407,7 +2386,7 @@ "(14264, 17)" ] }, - "execution_count": 89, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -2419,7 +2398,7 @@ }, { "cell_type": "code", - "execution_count": 90, + "execution_count": 28, "id": "0e30e0ac", "metadata": {}, "outputs": [ @@ -2434,7 +2413,7 @@ " dtype='object')" ] }, - "execution_count": 90, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -2446,7 +2425,7 @@ }, { "cell_type": "code", - "execution_count": 91, + "execution_count": 29, "id": "1ca6278f", "metadata": {}, "outputs": [ @@ -2465,7 +2444,7 @@ "type": "unknown" } ], - "ref": "cf99f66f-5f2c-41ef-8cf4-870772e10c73", + "ref": "3dae3a1a-f38b-47f9-a4a7-98ef9e3b6c52", "rows": [ [ "ANNEE_CTR", @@ -2562,7 +2541,7 @@ "dtype: object" ] }, - "execution_count": 91, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -2583,7 +2562,7 @@ }, { "cell_type": "code", - "execution_count": 92, + "execution_count": 30, "id": "184234b2", "metadata": {}, "outputs": [ @@ -2624,7 +2603,7 @@ }, { "cell_type": "code", - "execution_count": 93, + "execution_count": 31, "id": "74e39ca9", "metadata": {}, "outputs": [ @@ -2666,7 +2645,7 @@ }, { "cell_type": "code", - "execution_count": 94, + "execution_count": 32, "id": "0be945ad", "metadata": {}, "outputs": [ @@ -3528,7 +3507,7 @@ }, { "cell_type": "code", - "execution_count": 95, + "execution_count": 33, "id": "762adc47", "metadata": {}, "outputs": [ @@ -18645,7 +18624,7 @@ }, { "cell_type": "code", - "execution_count": 96, + "execution_count": 34, "id": "bb7eaef1", "metadata": {}, "outputs": [ @@ -33762,7 +33741,7 @@ }, { "cell_type": "code", - "execution_count": 97, + "execution_count": 35, "id": "01231a32", "metadata": {}, "outputs": [ @@ -48879,7 +48858,7 @@ }, { "cell_type": "code", - "execution_count": 98, + "execution_count": 36, "id": "1535eec5", "metadata": {}, "outputs": [ @@ -63996,7 +63975,7 @@ }, { "cell_type": "code", - "execution_count": 99, + "execution_count": 37, "id": "71dfb629", "metadata": {}, "outputs": [ @@ -64851,7 +64830,7 @@ }, { "cell_type": "code", - "execution_count": 100, + "execution_count": 38, "id": "27489ee0", "metadata": {}, "outputs": [ @@ -79976,7 +79955,7 @@ }, { "cell_type": "code", - "execution_count": 101, + "execution_count": 39, "id": "e833f992", "metadata": {}, "outputs": [ @@ -80010,7 +79989,7 @@ }, { "cell_type": "code", - "execution_count": 102, + "execution_count": 40, "id": "a5fd2159", "metadata": {}, "outputs": [], @@ -80025,7 +80004,7 @@ }, { "cell_type": "code", - "execution_count": 103, + "execution_count": 41, "id": "7c73dd35", "metadata": {}, "outputs": [], @@ -80038,7 +80017,7 @@ }, { "cell_type": "code", - "execution_count": 104, + "execution_count": 42, "id": "50b1c279", "metadata": {}, "outputs": [ @@ -80926,918 +80905,10 @@ "**Exercice :** Tracez un graphique permettant de visualiser la distribution des coûts des sinistres " ] }, - { - "cell_type": "code", - "execution_count": 105, - "id": "9b344a1e", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Eléments dans la liste 2 mais pas dans la liste 1 \n", - "[np.int64(3)]\n", - "Eléments dans la liste 1 mais pas dans la liste 2 :\n", - "[]\n" - ] - }, - { - "data": { - "application/vnd.plotly.v1+json": { - "config": { - "plotlyServerURL": "https://plot.ly" - }, - "data": [ - { - "name": "Hommes", - "orientation": "h", - "type": "bar", - "x": { - "bdata": "MByjARcAAQA=", - "dtype": "i2" - }, - "y": { - "bdata": "AAECAw==", - "dtype": "i1" - } - }, - { - "name": "Femmes", - "orientation": "h", - "type": "bar", - "x": { - "bdata": "b+q6/vD/", - "dtype": "i2" - }, - "y": { - "bdata": "AAECAw==", - "dtype": "i1" - } - } - ], - "layout": { - "bargap": 0, - "bargroupgap": 0, - "barmode": "relative", - "template": { - "data": { - "bar": [ - { - "error_x": { - "color": "#2a3f5f" - }, - "error_y": { - "color": "#2a3f5f" - }, - "marker": { - "line": { - "color": "#E5ECF6", - "width": 0.5 - }, - "pattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - } - }, - "type": "bar" - } - ], - "barpolar": [ - { - "marker": { - "line": { - "color": "#E5ECF6", - "width": 0.5 - }, - "pattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - } - }, - "type": "barpolar" - } - ], - "carpet": [ - { - "aaxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" - }, - "baxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" - }, - "type": "carpet" - } - ], - "choropleth": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "type": "choropleth" - } - ], - "contour": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "contour" - } - ], - "contourcarpet": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "type": "contourcarpet" - } - ], - "heatmap": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "heatmap" - } - ], - "histogram": [ - { - "marker": { - "pattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - } - }, - "type": "histogram" - } - ], - "histogram2d": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "histogram2d" - } - ], - "histogram2dcontour": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "histogram2dcontour" - } - ], - "mesh3d": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "type": "mesh3d" - } - ], - "parcoords": [ - { - "line": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "parcoords" - } - ], - "pie": [ - { - "automargin": true, - "type": "pie" - } - ], - "scatter": [ - { - "fillpattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - }, - "type": "scatter" - } - ], - "scatter3d": [ - { - "line": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatter3d" - } - ], - "scattercarpet": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattercarpet" - } - ], - "scattergeo": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattergeo" - } - ], - "scattergl": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattergl" - } - ], - "scattermap": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattermap" - } - ], - "scattermapbox": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattermapbox" - } - ], - "scatterpolar": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatterpolar" - } - ], - "scatterpolargl": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatterpolargl" - } - ], - "scatterternary": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatterternary" - } - ], - "surface": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "surface" - } - ], - "table": [ - { - "cells": { - "fill": { - "color": "#EBF0F8" - }, - "line": { - "color": "white" - } - }, - "header": { - "fill": { - "color": "#C8D4E3" - }, - "line": { - "color": "white" - } - }, - "type": "table" - } - ] - }, - "layout": { - "annotationdefaults": { - "arrowcolor": "#2a3f5f", - "arrowhead": 0, - "arrowwidth": 1 - }, - "autotypenumbers": "strict", - "coloraxis": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "colorscale": { - "diverging": [ - [ - 0, - "#8e0152" - ], - [ - 0.1, - "#c51b7d" - ], - [ - 0.2, - "#de77ae" - ], - [ - 0.3, - "#f1b6da" - ], - [ - 0.4, - "#fde0ef" - ], - [ - 0.5, - "#f7f7f7" - ], - [ - 0.6, - "#e6f5d0" - ], - [ - 0.7, - "#b8e186" - ], - [ - 0.8, - "#7fbc41" - ], - [ - 0.9, - "#4d9221" - ], - [ - 1, - "#276419" - ] - ], - "sequential": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "sequentialminus": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ] - }, - "colorway": [ - "#636efa", - "#EF553B", - "#00cc96", - "#ab63fa", - "#FFA15A", - "#19d3f3", - "#FF6692", - "#B6E880", - "#FF97FF", - "#FECB52" - ], - "font": { - "color": "#2a3f5f" - }, - "geo": { - "bgcolor": "white", - "lakecolor": "white", - "landcolor": "#E5ECF6", - "showlakes": true, - "showland": true, - "subunitcolor": "white" - }, - "hoverlabel": { - "align": "left" - }, - "hovermode": "closest", - "mapbox": { - "style": "light" - }, - "paper_bgcolor": "white", - "plot_bgcolor": "#E5ECF6", - "polar": { - "angularaxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - }, - "bgcolor": "#E5ECF6", - "radialaxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - } - }, - "scene": { - "xaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", - "gridwidth": 2, - "linecolor": "white", - "showbackground": true, - "ticks": "", - "zerolinecolor": "white" - }, - "yaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", - "gridwidth": 2, - "linecolor": "white", - "showbackground": true, - "ticks": "", - "zerolinecolor": "white" - }, - "zaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", - "gridwidth": 2, - "linecolor": "white", - "showbackground": true, - "ticks": "", - "zerolinecolor": "white" - } - }, - "shapedefaults": { - "line": { - "color": "#2a3f5f" - } - }, - "ternary": { - "aaxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - }, - "baxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - }, - "bgcolor": "#E5ECF6", - "caxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - } - }, - "title": { - "x": 0.05 - }, - "xaxis": { - "automargin": true, - "gridcolor": "white", - "linecolor": "white", - "ticks": "", - "title": { - "standoff": 15 - }, - "zerolinecolor": "white", - "zerolinewidth": 2 - }, - "yaxis": { - "automargin": true, - "gridcolor": "white", - "linecolor": "white", - "ticks": "", - "title": { - "standoff": 15 - }, - "zerolinecolor": "white", - "zerolinewidth": 2 - } - } - }, - "title": { - "font": { - "size": 22 - }, - "text": "Population du portefeuille" - }, - "xaxis": { - "title": { - "font": { - "size": 14 - }, - "text": "Count" - } - }, - "yaxis": { - "title": { - "font": { - "size": 14 - }, - "text": "Nombre de sinistres" - } - } - } - } - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "#Ecrivez votre code ici\n", - "#Préparation des données : compter le nombre de femmes et hommes par âge\n", - "tmp = data_set[[\"NB\",\"GENRE\"]].value_counts().to_frame('counts').reset_index()\n", - "data_f = tmp[tmp[\"GENRE\"] == \"F\"]\n", - "data_h = tmp[tmp[\"GENRE\"] == \"M\"]\n", - "\n", - "#Comparaison des âges\n", - "list_1=sorted(data_f[\"NB\"].unique())\n", - "list_2=sorted(data_h[\"NB\"].unique())\n", - "\n", - "print(\"Eléments dans la liste 2 mais pas dans la liste 1 \")\n", - "print(list(set(list_2) - set(list_1)))\n", - "\n", - "print(\"Eléments dans la liste 1 mais pas dans la liste 2 :\")\n", - "print(list(set(list_1) - set(list_2)))\n", - "\n", - "#On ordonne les dataframes\n", - "data_h = data_h.sort_values('NB', ascending = True)\n", - "data_f = data_f.sort_values('NB', ascending = True)\n", - "\n", - "y_age = data_h['NB']\n", - "x_M = data_h['counts']\n", - "x_F = data_f['counts'] * -1\n", - "\n", - "fig = gp.Figure()\n", - "\n", - "# Ajout des données H\n", - "fig.add_trace(gp.Bar(y= y_age, x = x_M,\n", - " name = 'Hommes',\n", - " orientation = 'h'))\n", - "\n", - "# Ajout des données F\n", - "fig.add_trace(gp.Bar(y = y_age, x = x_F,\n", - " name = 'Femmes', orientation = 'h'))\n", - "\n", - "# layout du graphique\n", - "fig.update_layout(title = 'Population du portefeuille',\n", - " title_font_size = 22, barmode = 'relative',\n", - " bargap = 0.0, bargroupgap = 0,\n", - " xaxis = {'title': 'Count',\n", - " 'title_font_size': 14},\n", - " yaxis = {'title': 'Nombre de sinistres',\n", - " 'title_font_size': 14}\n", - " )\n", - "\n", - "fig" - ] - }, { "cell_type": "code", "execution_count": null, - "id": "5ad37bf8", + "id": "9b344a1e", "metadata": {}, "outputs": [], "source": [] @@ -81884,386 +80955,33 @@ }, { "cell_type": "code", - "execution_count": 106, + "execution_count": 44, "id": "efd61bfc", "metadata": {}, "outputs": [ { - "data": { - "application/vnd.microsoft.datawrangler.viewer.v0+json": { - "columns": [ - { - "name": "index", - "rawType": "int64", - "type": "integer" - }, - { - "name": "ANNEE_CTR", - "rawType": "int64", - "type": "integer" - }, - { - "name": "CONTRAT_ANCIENNETE", - "rawType": "object", - "type": "string" - }, - { - "name": "FREQUENCE_PAIEMENT_COTISATION", - "rawType": "object", - "type": "string" - }, - { - "name": "GROUPE_KM", - "rawType": "object", - "type": "string" - }, - { - "name": "ZONE_RISQUE", - "rawType": "object", - "type": "string" - }, - { - "name": "AGE_ASSURE_PRINCIPAL", - "rawType": "int64", - "type": "integer" - }, - { - "name": "GENRE", - "rawType": "object", - "type": "unknown" - }, - { - "name": "DEUXIEME_CONDUCTEUR", - "rawType": "object", - "type": "unknown" - }, - { - "name": "ANCIENNETE_PERMIS", - "rawType": "int64", - "type": "integer" - }, - { - "name": "ANNEE_CONSTRUCTION", - "rawType": "float64", - "type": "float" - }, - { - "name": "ENERGIE", - "rawType": "object", - "type": "string" - }, - { - "name": "EQUIPEMENT_SECURITE", - "rawType": "object", - "type": "string" - }, - { - "name": "VALEUR_DU_BIEN", - "rawType": "object", - "type": "string" - }, - { - "name": "NB", - "rawType": "int64", - "type": "integer" - }, - { - "name": "CHARGE", - "rawType": "float64", - "type": "float" - }, - { - "name": "EXPO", - "rawType": "float64", - "type": "float" - } - ], - "ref": "12f908dd-992d-4aa3-a42f-2af790333222", - "rows": [ - [ - "0", - "2019", - "(-1,0]", - "ANNUEL", - "[20000;40000[", - "B", - "54", - "M", - "False", - "47", - "2016.0", - "ESSENCE", - "FAUX", - "[10000;15000[", - "0", - "0.0", - "0.672131147540984" - ], - [ - "1", - "2019", - "(-1,0]", - "ANNUEL", - "[20000;40000[", - "B", - "88", - "F", - "True", - "55", - "2018.0", - "DIESEL", - "VRAI", - "[20000;25000[", - "0", - "0.0", - "0.631147540983607" - ], - [ - "2", - "2021", - "(1,2]", - "ANNUEL", - "[0;20000[", - "D", - "35", - "F", - "True", - "16", - "2017.0", - "ESSENCE", - "FAUX", - "[15000;20000[", - "0", - "0.0", - "0.821917808219178" - ], - [ - "3", - "2021", - "(2,5]", - "ANNUEL", - "[0;20000[", - "C", - "46", - null, - "False", - "44", - "2018.0", - "ESSENCE", - "VRAI", - "[35000;99999[", - "0", - "0.0", - "0.832876712328767" - ], - [ - "4", - "2018", - "(2,5]", - "MENSUEL", - "[20000;40000[", - "A", - "46", - "F", - "False", - "31", - "2009.0", - "DIESEL", - "FAUX", - "[10000;15000[", - "0", - "0.0", - "1.0" - ] - ], - "shape": { - "columns": 16, - "rows": 5 - } - }, - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
ANNEE_CTRCONTRAT_ANCIENNETEFREQUENCE_PAIEMENT_COTISATIONGROUPE_KMZONE_RISQUEAGE_ASSURE_PRINCIPALGENREDEUXIEME_CONDUCTEURANCIENNETE_PERMISANNEE_CONSTRUCTIONENERGIEEQUIPEMENT_SECURITEVALEUR_DU_BIENNBCHARGEEXPO
02019(-1,0]ANNUEL[20000;40000[B54MFalse472016.0ESSENCEFAUX[10000;15000[00.00.672131
12019(-1,0]ANNUEL[20000;40000[B88FTrue552018.0DIESELVRAI[20000;25000[00.00.631148
22021(1,2]ANNUEL[0;20000[D35FTrue162017.0ESSENCEFAUX[15000;20000[00.00.821918
32021(2,5]ANNUEL[0;20000[C46NaNFalse442018.0ESSENCEVRAI[35000;99999[00.00.832877
42018(2,5]MENSUEL[20000;40000[A46FFalse312009.0DIESELFAUX[10000;15000[00.01.000000
\n", - "
" - ], - "text/plain": [ - " ANNEE_CTR CONTRAT_ANCIENNETE FREQUENCE_PAIEMENT_COTISATION GROUPE_KM \\\n", - "0 2019 (-1,0] ANNUEL [20000;40000[ \n", - "1 2019 (-1,0] ANNUEL [20000;40000[ \n", - "2 2021 (1,2] ANNUEL [0;20000[ \n", - "3 2021 (2,5] ANNUEL [0;20000[ \n", - "4 2018 (2,5] MENSUEL [20000;40000[ \n", - "\n", - " ZONE_RISQUE AGE_ASSURE_PRINCIPAL GENRE DEUXIEME_CONDUCTEUR \\\n", - "0 B 54 M False \n", - "1 B 88 F True \n", - "2 D 35 F True \n", - "3 C 46 NaN False \n", - "4 A 46 F False \n", - "\n", - " ANCIENNETE_PERMIS ANNEE_CONSTRUCTION ENERGIE EQUIPEMENT_SECURITE \\\n", - "0 47 2016.0 ESSENCE FAUX \n", - "1 55 2018.0 DIESEL VRAI \n", - "2 16 2017.0 ESSENCE FAUX \n", - "3 44 2018.0 ESSENCE VRAI \n", - "4 31 2009.0 DIESEL FAUX \n", - "\n", - " VALEUR_DU_BIEN NB CHARGE EXPO \n", - "0 [10000;15000[ 0 0.0 0.672131 \n", - "1 [20000;25000[ 0 0.0 0.631148 \n", - "2 [15000;20000[ 0 0.0 0.821918 \n", - "3 [35000;99999[ 0 0.0 0.832877 \n", - "4 [10000;15000[ 0 0.0 1.000000 " - ] - }, - "execution_count": 106, - "metadata": {}, - "output_type": "execute_result" + "ename": "TypeError", + "evalue": "DataFrame.dropna() got an unexpected keyword argument 'columns'", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mTypeError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[44]\u001b[39m\u001b[32m, line 4\u001b[39m\n\u001b[32m 1\u001b[39m data_retraitee = data_set\n\u001b[32m 3\u001b[39m \u001b[38;5;66;03m# Option 1 : pour la variable \"PUISSANCE_VEHICULE\"\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m4\u001b[39m data_retraitee = \u001b[43mdata_retraitee\u001b[49m\u001b[43m.\u001b[49m\u001b[43mdropna\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcolumns\u001b[49m\u001b[43m=\u001b[49m\u001b[43m[\u001b[49m\u001b[33;43m'\u001b[39;49m\u001b[33;43mPUISSANCE_VEHICULE\u001b[39;49m\u001b[33;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 5\u001b[39m data_retraitee.head()\n", + "\u001b[31mTypeError\u001b[39m: DataFrame.dropna() got an unexpected keyword argument 'columns'" + ] } ], "source": [ "data_retraitee = data_set\n", "\n", "# Option 1 : pour la variable \"PUISSANCE_VEHICULE\"\n", - "data_retraitee = data_retraitee.drop(columns=['PUISSANCE_VEHICULE'])\n", + "data_retraitee = data_retraitee.dropna(columns=['PUISSANCE_VEHICULE'])\n", "data_retraitee.head()" ] }, { "cell_type": "code", - "execution_count": 107, + "execution_count": null, "id": "312ff05c", "metadata": {}, "outputs": [], @@ -82280,7 +80998,7 @@ }, { "cell_type": "code", - "execution_count": 108, + "execution_count": null, "id": "2f542319", "metadata": {}, "outputs": [], @@ -82294,7 +81012,7 @@ }, { "cell_type": "code", - "execution_count": 109, + "execution_count": null, "id": "b81a48e0", "metadata": {}, "outputs": [ @@ -82694,7 +81412,7 @@ }, { "cell_type": "code", - "execution_count": 110, + "execution_count": null, "id": "25fbe5cf", "metadata": {}, "outputs": [], @@ -82712,7 +81430,7 @@ }, { "cell_type": "code", - "execution_count": 111, + "execution_count": null, "id": "0b5caf1d", "metadata": {}, "outputs": [], @@ -82730,7 +81448,7 @@ }, { "cell_type": "code", - "execution_count": 112, + "execution_count": null, "id": "6a0f7afa", "metadata": {}, "outputs": [], @@ -82758,7 +81476,7 @@ }, { "cell_type": "code", - "execution_count": 113, + "execution_count": null, "id": "c0d7ebf9", "metadata": {}, "outputs": [], @@ -82795,7 +81513,7 @@ }, { "cell_type": "code", - "execution_count": 114, + "execution_count": null, "id": "d40508d7", "metadata": {}, "outputs": [ @@ -83670,7 +82388,7 @@ }, { "cell_type": "code", - "execution_count": 115, + "execution_count": null, "id": "1b7e6ff4", "metadata": {}, "outputs": [ @@ -84546,7 +83264,7 @@ }, { "cell_type": "code", - "execution_count": 116, + "execution_count": null, "id": "1ac452e1", "metadata": {}, "outputs": [ @@ -85437,7 +84155,7 @@ }, { "cell_type": "code", - "execution_count": 117, + "execution_count": null, "id": "2185245a", "metadata": {}, "outputs": [ @@ -86328,7 +85046,7 @@ }, { "cell_type": "code", - "execution_count": 118, + "execution_count": null, "id": "2e2486e5", "metadata": {}, "outputs": [], @@ -86346,7 +85064,7 @@ }, { "cell_type": "code", - "execution_count": 119, + "execution_count": null, "id": "63b97150", "metadata": {}, "outputs": [], @@ -86364,7 +85082,7 @@ }, { "cell_type": "code", - "execution_count": 120, + "execution_count": null, "id": "d1506c6c", "metadata": {}, "outputs": [], @@ -86382,7 +85100,7 @@ }, { "cell_type": "code", - "execution_count": 121, + "execution_count": null, "id": "9f19cc0d", "metadata": {}, "outputs": [], diff --git a/M2/SQL/Makefile b/M2/SQL/Makefile new file mode 100644 index 0000000..51d5238 --- /dev/null +++ b/M2/SQL/Makefile @@ -0,0 +1,4 @@ +# Makefile + +tp1: + docker exec -i M2_SQL_COURSE mysql -u root TP -t < ./scripts/TP1.sql | tee logs/last-run.log \ No newline at end of file diff --git a/M2/SQL/docker-compose.yml b/M2/SQL/docker-compose.yml new file mode 100644 index 0000000..faf7af5 --- /dev/null +++ b/M2/SQL/docker-compose.yml @@ -0,0 +1,13 @@ +services: + mysql: + container_name: M2_SQL_COURSE + image: mysql:latest + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: 'true' + MYSQL_DATABASE: TP + volumes: + - mysql_data:/var/lib/mysql + restart: unless-stopped + +volumes: + mysql_data: \ No newline at end of file diff --git a/M2/SQL/scripts/TP1.sql b/M2/SQL/scripts/TP1.sql new file mode 100644 index 0000000..fec8e44 --- /dev/null +++ b/M2/SQL/scripts/TP1.sql @@ -0,0 +1,50 @@ +DROP TABLE IF EXISTS Magasin; +DROP TABLE IF EXISTS Localite; + +-- Q1.1 +CREATE TABLE IF NOT EXISTS Magasin( + Id VARCHAR(3) PRIMARY KEY, + Enseigne VARCHAR(100) NOT NULL, + Ville VARCHAR(255) NOT NULL, + Chiffre INTEGER NOT NULL +); + +CREATE TABLE IF NOT EXISTS Localite( + Ville VARCHAR(255) NOT NULL, + Population INTEGER NOT NULL +); + +INSERT INTO Localite (Ville, Population) VALUES +('Créteil', 92984), +('Pantin', 60597), +('Colombes', 87328); + +INSERT INTO Magasin (Id, Enseigne, Ville, Chiffre) VALUES +('D10', 'Super Discount', 'Créteil', 2800000), +('I10', 'Inter Prix', 'Créteil', 1230000), +('T01', 'Leader Trade', 'Créteil', 830000), +('M01', 'Discount Market', 'Créteil', 1010000), +('T08', 'Leader Trade', 'Pantin', 3230000), +('D20', 'Super Discount', 'Pantin', 556000), +('D22', 'Super Discount', 'Colombes', 4032000), +('T05', 'Leader Trade', 'Colombes', 2780000), +('I17', 'Inter Prix', 'Colombes', 3912000), +('M87', 'Discount Market', 'Colombes', 1471000), +('M89', 'Discount Market', 'Colombes', 845000); + +SELECT * FROM Magasin; +SELECT * FROM Localite; + +-- Q1.2 +SELECT Ville, COUNT(*) AS NombreMagasins +FROM Magasin +GROUP BY Ville +ORDER BY Ville ASC; + +-- Q1.3 +SELECT Ville, Enseigne, COUNT(*) as NombreMagasins +FROM Magasin +GROUP BY Ville, Enseigne +HAVING NombreMagasins >= 2; + +-- Q1.4