{"cells":[{"source":"","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"," | SN_30_siren | \n","SN_10_denominationUniteLegale | \n","ANNULATION | \n","APPEL_OFFRE | \n","ATTRIBUTION | \n","EX_ANTE_VOLONTAIRE | \n","MODIFICATION | \n","PERIODIQUE | \n","PRE-INFORMATION | \n","RECTIFICATIF | \n","
---|---|---|---|---|---|---|---|---|---|---|
0 | \n","533969457 | \n","SPL AGENCE REGIONALE DE L'AMENAGEMENT ET DE LA CONSTRUCTION OCCITANIE | \n","<NA> | \n","14 | \n","1 | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","4 | \n","
1 | \n","268000148 | \n","CENTRE HOSPITALIER UNIVERSITAIRE | \n","<NA> | \n","10 | \n","5 | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","
2 | \n","180092082 | \n","OPERATEUR DU PATRIMOINE ET DES PROJETS IMMOBILIERS DE LA CULTURE | \n","<NA> | \n","9 | \n","1 | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","1 | \n","
3 | \n","200030195 | \n","METROPOLE NICE COTE D AZUR | \n","<NA> | \n","8 | \n","8 | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","
4 | \n","180020026 | \n","CAISSE DES DEPOTS ET CONSIGNATIONS | \n","<NA> | \n","7 | \n","4 | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","
5 | \n","200065597 | \n","CU CAEN LA MER | \n","<NA> | \n","7 | \n","2 | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","
6 | \n","256702960 | \n","SMICTOM D'ALSACE CENTRALE | \n","<NA> | \n","6 | \n","1 | \n","1 | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","
7 | \n","243300316 | \n","BORDEAUX METROPOLE | \n","<NA> | \n","6 | \n","2 | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","
8 | \n","265906735 | \n","CENTRE HOSPITALIER DE VALENCIENNES | \n","<NA> | \n","6 | \n","2 | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","1 | \n","
9 | \n","257550004 | \n","SYNDICAT INTERDEPARTEMENTAL POUR L ASSAINISSEMENT DE L AGGLOMERATION PARISIENNE | \n","<NA> | \n","6 | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","<NA> | \n","