{"cells":[{"source":"\"Kaggle\"","metadata":{},"cell_type":"markdown"},{"cell_type":"code","execution_count":1,"id":"0b90c754","metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","execution":{"iopub.execute_input":"2024-12-25T07:19:06.373071Z","iopub.status.busy":"2024-12-25T07:19:06.372655Z","iopub.status.idle":"2024-12-25T07:19:07.29999Z","shell.execute_reply":"2024-12-25T07:19:07.298785Z"},"papermill":{"duration":0.933809,"end_time":"2024-12-25T07:19:07.302617","exception":false,"start_time":"2024-12-25T07:19:06.368808","status":"completed"},"tags":[]},"outputs":[],"source":["import pandas as pd\n","pd.set_option('display.max_columns', 100)\n","pd.set_option('display.max_rows', 100)\n","pd.set_option('display.max_colwidth', 200)\n","\n","from IPython.core.interactiveshell import InteractiveShell\n","InteractiveShell.ast_node_interactivity ='all'"]},{"cell_type":"code","execution_count":2,"id":"ea42cccd","metadata":{"execution":{"iopub.execute_input":"2024-12-25T07:19:07.308402Z","iopub.status.busy":"2024-12-25T07:19:07.307857Z","iopub.status.idle":"2024-12-25T07:19:07.317037Z","shell.execute_reply":"2024-12-25T07:19:07.316094Z"},"papermill":{"duration":0.014479,"end_time":"2024-12-25T07:19:07.319217","exception":false,"start_time":"2024-12-25T07:19:07.304738","status":"completed"},"tags":[]},"outputs":[],"source":["def top_acheteurs_assurances_boamp(nbre_top):\n"," df_ = pd.read_csv('https://www.data.gouv.fr/fr/datasets/r/0c64e17e-0d54-4e34-b8a1-3a13cccae522',\n"," dtype='string',\n"," sep=';',\n"," usecols=['SN_30_siren','SN_10_denominationUniteLegale', 'B_20_nature' ,'B_09_dateParution'])\n"," \n"," df_dd = df_.loc[:,['SN_30_siren','SN_10_denominationUniteLegale']].drop_duplicates()\n","\n"," print(f\"Dernière date prise en compte: -> le {df_.B_09_dateParution.max()}\" )\n"," df_ = df_.drop(columns=['B_09_dateParution'])\n","\n"," return (pd\n"," .pivot_table(df_, index=['SN_30_siren'], values=['B_20_nature'],\n"," columns='B_20_nature', aggfunc=\"count\")\n"," .astype('Int64')\n"," .droplevel(0, axis=1) \n"," .merge(df_dd, how='left', left_index=True, right_on='SN_30_siren') \n"," .loc[:, ['SN_30_siren','SN_10_denominationUniteLegale',\n"," 'ANNULATION','APPEL_OFFRE','ATTRIBUTION', \n"," 'EX_ANTE_VOLONTAIRE', 'MODIFICATION', 'PERIODIQUE', \n"," 'PRE-INFORMATION','RECTIFICATIF']]\n"," .sort_values(by='APPEL_OFFRE', ascending=False)\n"," .reset_index(drop=True)\n"," .iloc[:nbre_top, :]\n"," )"]},{"cell_type":"code","execution_count":3,"id":"e6be8295","metadata":{"execution":{"iopub.execute_input":"2024-12-25T07:19:07.324704Z","iopub.status.busy":"2024-12-25T07:19:07.324319Z","iopub.status.idle":"2024-12-25T07:19:09.400536Z","shell.execute_reply":"2024-12-25T07:19:09.399221Z"},"papermill":{"duration":2.082178,"end_time":"2024-12-25T07:19:09.403408","exception":false,"start_time":"2024-12-25T07:19:07.32123","status":"completed"},"tags":[]},"outputs":[{"name":"stdout","output_type":"stream","text":["Dernière date prise en compte: -> le 2024-12-24\n"]},{"data":{"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"," \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","
SN_30_sirenSN_10_denominationUniteLegaleANNULATIONAPPEL_OFFREATTRIBUTIONEX_ANTE_VOLONTAIREMODIFICATIONPERIODIQUEPRE-INFORMATIONRECTIFICATIF
0533969457SPL AGENCE REGIONALE DE L'AMENAGEMENT ET DE LA CONSTRUCTION OCCITANIE<NA>141<NA><NA><NA><NA>4
1268000148CENTRE HOSPITALIER UNIVERSITAIRE<NA>105<NA><NA><NA><NA><NA>
2180092082OPERATEUR DU PATRIMOINE ET DES PROJETS IMMOBILIERS DE LA CULTURE<NA>91<NA><NA><NA><NA>1
3200030195METROPOLE NICE COTE D AZUR<NA>88<NA><NA><NA><NA><NA>
4180020026CAISSE DES DEPOTS ET CONSIGNATIONS<NA>74<NA><NA><NA><NA><NA>
5200065597CU CAEN LA MER<NA>72<NA><NA><NA><NA><NA>
6256702960SMICTOM D'ALSACE CENTRALE<NA>611<NA><NA><NA><NA>
7243300316BORDEAUX METROPOLE<NA>62<NA><NA><NA><NA><NA>
8265906735CENTRE HOSPITALIER DE VALENCIENNES<NA>62<NA><NA><NA><NA>1
9257550004SYNDICAT INTERDEPARTEMENTAL POUR L ASSAINISSEMENT DE L AGGLOMERATION PARISIENNE<NA>6<NA><NA><NA><NA><NA><NA>
\n","
"],"text/plain":[" SN_30_siren \\\n","0 533969457 \n","1 268000148 \n","2 180092082 \n","3 200030195 \n","4 180020026 \n","5 200065597 \n","6 256702960 \n","7 243300316 \n","8 265906735 \n","9 257550004 \n","\n"," SN_10_denominationUniteLegale \\\n","0 SPL AGENCE REGIONALE DE L'AMENAGEMENT ET DE LA CONSTRUCTION OCCITANIE \n","1 CENTRE HOSPITALIER UNIVERSITAIRE \n","2 OPERATEUR DU PATRIMOINE ET DES PROJETS IMMOBILIERS DE LA CULTURE \n","3 METROPOLE NICE COTE D AZUR \n","4 CAISSE DES DEPOTS ET CONSIGNATIONS \n","5 CU CAEN LA MER \n","6 SMICTOM D'ALSACE CENTRALE \n","7 BORDEAUX METROPOLE \n","8 CENTRE HOSPITALIER DE VALENCIENNES \n","9 SYNDICAT INTERDEPARTEMENTAL POUR L ASSAINISSEMENT DE L AGGLOMERATION PARISIENNE \n","\n"," ANNULATION APPEL_OFFRE ATTRIBUTION EX_ANTE_VOLONTAIRE MODIFICATION \\\n","0 14 1 \n","1 10 5 \n","2 9 1 \n","3 8 8 \n","4 7 4 \n","5 7 2 \n","6 6 1 1 \n","7 6 2 \n","8 6 2 \n","9 6 \n","\n"," PERIODIQUE PRE-INFORMATION RECTIFICATIF \n","0 4 \n","1 \n","2 1 \n","3 \n","4 \n","5 \n","6 \n","7 \n","8 1 \n","9 "]},"execution_count":3,"metadata":{},"output_type":"execute_result"}],"source":["top_acheteurs_assurances_boamp(10)\n"]},{"cell_type":"code","execution_count":null,"id":"84bf2278","metadata":{"papermill":{"duration":0.002237,"end_time":"2024-12-25T07:19:09.408214","exception":false,"start_time":"2024-12-25T07:19:09.405977","status":"completed"},"tags":[]},"outputs":[],"source":[]}],"metadata":{"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":30804,"isGpuEnabled":false,"isInternetEnabled":true,"language":"python","sourceType":"notebook"},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.14"},"papermill":{"default_parameters":{},"duration":6.975505,"end_time":"2024-12-25T07:19:09.931905","environment_variables":{},"exception":null,"input_path":"__notebook__.ipynb","output_path":"__notebook__.ipynb","parameters":{},"start_time":"2024-12-25T07:19:02.9564","version":"2.6.0"}},"nbformat":4,"nbformat_minor":5}