Spaces:
Runtime error
Runtime error
File size: 2,368 Bytes
bdbfec0 c6aa119 fadc8f0 1883e68 fadc8f0 c6aa119 f8cfe0e 2c9e460 f8cfe0e b9b1499 f88e06d e95156c fadc8f0 b9b1499 f8cfe0e e95156c 2c9e460 e95156c f8cfe0e b9b1499 f8cfe0e b9b1499 f8cfe0e b9b1499 e95156c 4b29661 fadc8f0 b807d87 6983fe3 e95156c 6983fe3 e95156c 6983fe3 fadc8f0 895d632 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
import streamlit as st
import pandas as pd
import requests
import folium
from streamlit_folium import folium_static
def get_data():
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
records = data.get("records", [])
cleaned_data = []
for record in records:
fields = record.get("fields", {})
# Assurez-vous que les champs nécessaires existent
if all(key in fields for key in ['nom_courant_denomination', 'commune', 'libelle_section_naf', 'tranche_effectif_entreprise', 'action_rse']):
cleaned_data.append(fields)
return cleaned_data
else:
return []
def display_organisations_engagees(data):
st.markdown("## OPEN DATA RSE")
st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
if data:
df = pd.DataFrame(data)
df = df[['nom_courant_denomination', 'commune', 'libelle_section_naf', 'tranche_effectif_entreprise', 'action_rse']]
df.rename(columns={
'nom_courant_denomination': 'Nom',
'commune': 'Commune',
'libelle_section_naf': 'Section NAF',
'tranche_effectif_entreprise': 'Effectif',
'action_rse': 'Action RSE'
}, inplace=True)
st.dataframe(df)
else:
st.write("Aucune donnée disponible.")
def display_map(data):
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
for item in data:
geoloc = item.get('geolocalisation')
if geoloc:
folium.Marker(
location=[geoloc[0], geoloc[1]],
icon=folium.Icon(color="green", icon="leaf"),
popup=item.get('nom_courant_denomination', 'Information non disponible'),
).add_to(m)
folium_static(m)
def main():
st.sidebar.title("Navigation")
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Localisation des Entreprises"])
data = get_data()
if app_mode == "Organisations engagées":
display_organisations_engagees(data)
elif app_mode == "Localisation des Entreprises":
display_map(data)
if __name__ == "__main__":
main()
|