LaurentTRIPIED commited on
Commit
895d632
1 Parent(s): f8309b3
Files changed (1) hide show
  1. app.py +21 -13
app.py CHANGED
@@ -4,7 +4,7 @@ import requests
4
  import folium
5
  from streamlit_folium import folium_static
6
 
7
- # Fonction pour récupérer les données de l'API (ajustez selon vos besoins)
8
  def get_data():
9
  url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
10
  response = requests.get(url)
@@ -23,28 +23,36 @@ def display_organisations_engagees():
23
  data, _ = get_data()
24
  if data:
25
  df = pd.DataFrame(data)
26
- # Sélection et réorganisation des colonnes
27
- df = df[["nom_courant_denomination", "commune", "libelle_section_naf", "tranche_effectif_entreprise", "action_rse"]]
28
- st.dataframe(df, width=None, height=None) # Ajustez width et height si nécessaire
 
 
 
 
 
 
29
 
30
- # Fonction pour afficher la carte avec Folium (à ajuster selon vos données)
31
  def display_map():
32
  data, _ = get_data()
33
  if data:
34
- # Création d'une carte centrée autour de Bordeaux
35
- m = folium.Map(location=[44.8378, -0.5792], zoom_start=12)
36
- # Ajout des entreprises sur la carte
37
  for item in data:
38
- if 'geolocalisation' in item:
39
- folium.Marker(location=[item['geolocalisation'][0], item['geolocalisation'][1]],
40
- popup=item["nom_courant_denomination"]).add_to(m)
 
 
 
 
41
  folium_static(m)
42
 
43
  # Fonction pour l'onglet "Dialoguer avec l'assistant IA RSE bziiit"
44
  def display_dialogue():
45
  st.markdown("# Patientez quelques heures encore... :)")
46
 
47
- # Création des onglets de l'application
48
  def main():
49
  st.sidebar.title("Navigation")
50
  app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Carte", "Dialoguer avec l'assistant IA RSE bziiit"])
@@ -57,4 +65,4 @@ def main():
57
  display_dialogue()
58
 
59
  if __name__ == "__main__":
60
- main()
 
4
  import folium
5
  from streamlit_folium import folium_static
6
 
7
+ # Fonction pour récupérer les données de l'API
8
  def get_data():
9
  url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
10
  response = requests.get(url)
 
23
  data, _ = get_data()
24
  if data:
25
  df = pd.DataFrame(data)
26
+ df = df.rename(columns={
27
+ "nom_courant_denomination": "Nom",
28
+ "commune": "Commune",
29
+ "libelle_section_naf": "Section NAF",
30
+ "tranche_effectif_entreprise": "Effectif",
31
+ "action_rse": "Action RSE"
32
+ })
33
+ df = df[["Nom", "Commune", "Section NAF", "Effectif", "Action RSE"]]
34
+ st.dataframe(df, width=None, height=None)
35
 
36
+ # Fonction pour afficher la carte
37
  def display_map():
38
  data, _ = get_data()
39
  if data:
40
+ m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
 
 
41
  for item in data:
42
+ if 'point_geo' in item and item['point_geo'] is not None:
43
+ lat = item['point_geo']['lat']
44
+ lon = item['point_geo']['lon']
45
+ folium.Marker(
46
+ [lat, lon],
47
+ popup=item.get("Nom", "Sans nom")
48
+ ).add_to(m)
49
  folium_static(m)
50
 
51
  # Fonction pour l'onglet "Dialoguer avec l'assistant IA RSE bziiit"
52
  def display_dialogue():
53
  st.markdown("# Patientez quelques heures encore... :)")
54
 
55
+ # Main function to orchestrate the app UI
56
  def main():
57
  st.sidebar.title("Navigation")
58
  app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Carte", "Dialoguer avec l'assistant IA RSE bziiit"])
 
65
  display_dialogue()
66
 
67
  if __name__ == "__main__":
68
+ main()