Skip to content

Instantly share code, notes, and snippets.

View AuFilDuBoamp's full-sized avatar

Jean-Marie FALVET | Data Broker B2B | AuFilDuBoamp AuFilDuBoamp

View GitHub Profile
dico_py_replace_calendar_en_to_fr = {
"Monday": "Lundi",
"Tuesday": "Mardi",
"Wednesday": "Mercredi",
"Thursday": "Jeudi",
"Friday": "Vendredi",
"Saturday": "Samedi",
"Sunday": "Dimanche",
"January": "Janvier",
"February": "Février",
@AuFilDuBoamp
AuFilDuBoamp / comment-telecharger-la-table-boamp-siren-acheteurs-80-d-aufilduboamp-avec-python-en-4-etapes.ipynb
Last active July 20, 2024 11:17
comment-telecharger-la-table-boamp-siren-acheteurs-80-d-aufilduboamp-avec-python-en-4-etapes.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Adresse du tableau BOAMP officiel (2024 - CSV)
URL = "https://boamp-datadila.opendatasoft.com/api/explore/v2.1/catalog/datasets/boamp/\
exports/csv?lang=fr&qv1=(dateparution%3A2024)&timezone=Europe%2FBerlin&use_labels=true&delimiter=%3B"
# Création de la Dataframe
df = pd.read_csv(URL, sep=';', low_memory=False, dtype='string', encoding='utf-8')
# Liste des Régions françaises et assimilées (au format SIRENE)
LISTE_REGIONS = [
"COLLECTIVITE DE CORSE",
"COLLECTIVITE TERRITORIALE DE GUYANE",
"COLLECTIVITE TERRITORIALE DE MARTINIQUE",
"CONSEIL REGIONAL DE LA GUADELOUPE",
"REGION AUVERGNE-RHONE-ALPES",
"REGION BOURGOGNE-FRANCHE-COMTE",
"REGION BRETAGNE",
"REGION CENTRE-VAL DE LOIRE",
# Fichier lié à l'article ► https://www.aufilduboamp.com/article3.html
# Importer pandas:
import pandas as pd
# Charger une copie du premier trimestre 2024 du tableau Boamp
# officiel versée sur notre dépôt Datagouv par confort:
df_boamp_t1_2024 = pd.read_parquet('https://www.data.gouv.fr/fr/datasets/r/f7a4a76e-ff50-4dc6-bae8-97368081add2')
# Maintenant charger le CSV des régions sur github:
# Fichier lié à l'article ► https://www.aufilduboamp.com/article211.html
# Importer pandas:
import pandas as pd
# Charger une copie du premier trimestre 2024 du tableau Boamp
# Panorama versée sur notre dépôt Datagouv:
df_boamp_t1_2024 = pd.read_parquet('https://www.data.gouv.fr/fr/datasets/r/e9942655-a7b9-4680-a174-02dab1039b49')
## Sélectionner les annonces du premier trimestre:
# Fichier lié à l'article ► https://www.aufilduboamp.com/article216.html
# Importer pandas:
import pandas as pd
# Charger une copie du premier trimestre 2024 du tableau
# BOAMP-SIREN-ACHETEURS (BSA) d'AuFilDuBoamp
df_boamp_t1_2024_bsa = pd.read_parquet('https://www.data.gouv.fr/fr/datasets/r/4b77da19-3834-4a12-9626-9aedd75d168a')
DEPARTEMENT_NOM_SIREN DEPARTEMENT_NUM_SIREN DEPARTEMENT_NUM_SIRET DEPARTEMENT_CP_SIEGE
0 DEPARTEMENT DE L AIN 220100010 22010001000010 01000
1 DEPARTEMENT DE L AISNE 220200026 22020002600015 02000
2 DEPARTEMENT DE L ALLIER 220300016 22030001600080 03000
3 DEPARTEMENT DES ALPES DE HAUTE PROVENCE 220400014 22040001400019 04000
4 DEPARTEMENT DES HAUTES ALPES 220500011 22050001100089 05000
5 DEPARTEMENT DES ALPES MARITIMES 220600019 22060001900016 06200
6 DEPARTEMENT DE L ARDECHE 220700017 22070001700019 07000
7 DEPARTEMENT DES ARDENNES 220800049 22080004900011 08000
8 DEPARTEMENT DE L ARIEGE 220900013 22090001300016 09000
COM_AGGLO_NOM_SIREN COM_AGGLO_NUM_SIREN COM_AGGLO_NUM_SIRET COM_AGGLO_DEP
0 HAUT - BUGEY AGGLOMERATION 200042935 20004293500011 01
1 CA DU BASSIN DE BOURG-EN-BRESSE 200071751 20007175100016 01
2 COMMUNAUTE D'AGGLOMERATION DU PAYS DE GEX 240100750 24010075000126 01
3 COMMUNAUTE D'AGGLOMERATION DU PAYS DE LAON 200043495 20004349500015 02
4 CA CHAUNY TERGNIER LA FERE 200071785 20007178500014 02
5 CA DU SAINT-QUENTINOIS 200071892 20007189200067 02
6 CA DE LA REGION DE CHATEAU-THIERRY 200072031 20007203100129 02
7 GRANDSOISSONS AGGLOMERATION 240200477 24020047700026 02
8 CA MONTLUCON COMMUNAUTE 200071082 20007108200016 03
METROPOLE_NOM_SIREN METROPOLE_NUM_SIREN METROPOLE_NUM_SIRET METROPOLE_DEP
0 METROPOLE NICE COTE D AZUR 200030195 20003019500115 06
1 METROPOLE D'AIX-MARSEILLE-PROVENCE 200054807 20005480700017 13
2 DIJON METROPOLE 242100410 24210041000123 21
3 BREST METROPOLE 242900314 24290031400012 29
4 TOULOUSE METROPOLE 243100518 24310051800170 31
5 BORDEAUX METROPOLE 243300316 24330031600011 33
6 MONTPELLIER MEDITERRANEE METROPOLE 243400017 24340001700022 34
7 RENNES METROPOLE 243500139 24350013900189 35
8 TOURS METROPOLE VAL DE LOIRE 243700754 24370075400035 37