Spaces:
Runtime error
Runtime error
Commit
·
8f47c03
1
Parent(s):
ad464ea
Pytorch V0.12
Browse files
app.py
CHANGED
|
@@ -10,56 +10,44 @@ def get_data():
|
|
| 10 |
if response.status_code == 200:
|
| 11 |
data = response.json()
|
| 12 |
records = data.get("records", [])
|
| 13 |
-
|
| 14 |
-
cleaned_data = [record.get("fields", {}) for record in records if record.get("fields", {})]
|
| 15 |
-
return cleaned_data
|
| 16 |
else:
|
| 17 |
return []
|
| 18 |
|
| 19 |
def display_organisations_engagees(data):
|
| 20 |
st.markdown("## OPEN DATA RSE")
|
| 21 |
st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
|
| 22 |
-
|
| 23 |
num_etablissements = len(data)
|
| 24 |
st.markdown(f"Nombre d'établissements : {num_etablissements}")
|
| 25 |
-
|
| 26 |
if data:
|
| 27 |
df = pd.DataFrame(data)
|
| 28 |
-
|
| 29 |
-
expected_columns = ['nom_courant_denomination', 'commune', 'libelle_section_naf', 'tranche_effectif_entreprise', 'action_rse']
|
| 30 |
-
for column in expected_columns:
|
| 31 |
-
if column not in df.columns:
|
| 32 |
-
df[column] = None # Ajouter la colonne manquante avec des valeurs None
|
| 33 |
-
df = df[expected_columns]
|
| 34 |
-
df.rename(columns={
|
| 35 |
'nom_courant_denomination': 'Nom',
|
| 36 |
'commune': 'Commune',
|
| 37 |
'libelle_section_naf': 'Section NAF',
|
| 38 |
'tranche_effectif_entreprise': 'Effectif',
|
| 39 |
'action_rse': 'Action RSE'
|
| 40 |
-
}
|
| 41 |
-
st.dataframe(df, height=800) # Réglage de la hauteur pour s'assurer de l'affichage de toutes les lignes
|
| 42 |
-
else:
|
| 43 |
-
st.write("Aucune donnée disponible.")
|
| 44 |
|
| 45 |
def display_map(data):
|
| 46 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
| 47 |
for item in data:
|
| 48 |
-
|
| 49 |
-
if
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 55 |
folium_static(m)
|
| 56 |
|
| 57 |
def main():
|
| 58 |
st.sidebar.title("Navigation")
|
| 59 |
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Localisation des Entreprises"])
|
| 60 |
-
|
| 61 |
data = get_data()
|
| 62 |
-
|
| 63 |
if app_mode == "Organisations engagées":
|
| 64 |
display_organisations_engagees(data)
|
| 65 |
elif app_mode == "Localisation des Entreprises":
|
|
|
|
| 10 |
if response.status_code == 200:
|
| 11 |
data = response.json()
|
| 12 |
records = data.get("records", [])
|
| 13 |
+
return [record.get("fields") for record in records]
|
|
|
|
|
|
|
| 14 |
else:
|
| 15 |
return []
|
| 16 |
|
| 17 |
def display_organisations_engagees(data):
|
| 18 |
st.markdown("## OPEN DATA RSE")
|
| 19 |
st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
|
|
|
|
| 20 |
num_etablissements = len(data)
|
| 21 |
st.markdown(f"Nombre d'établissements : {num_etablissements}")
|
|
|
|
| 22 |
if data:
|
| 23 |
df = pd.DataFrame(data)
|
| 24 |
+
st.dataframe(df[['nom_courant_denomination', 'commune', 'libelle_section_naf', 'tranche_effectif_entreprise', 'action_rse']].rename(columns={
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
'nom_courant_denomination': 'Nom',
|
| 26 |
'commune': 'Commune',
|
| 27 |
'libelle_section_naf': 'Section NAF',
|
| 28 |
'tranche_effectif_entreprise': 'Effectif',
|
| 29 |
'action_rse': 'Action RSE'
|
| 30 |
+
}))
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
def display_map(data):
|
| 33 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
| 34 |
for item in data:
|
| 35 |
+
point_geo = item.get('point_geo')
|
| 36 |
+
if point_geo:
|
| 37 |
+
lon = point_geo.get('lon')
|
| 38 |
+
lat = point_geo.get('lat')
|
| 39 |
+
if lon and lat:
|
| 40 |
+
folium.Marker(
|
| 41 |
+
[lat, lon],
|
| 42 |
+
icon=folium.Icon(color="green", icon="leaf"),
|
| 43 |
+
popup=item.get('nom_courant_denomination', 'Information non disponible'),
|
| 44 |
+
).add_to(m)
|
| 45 |
folium_static(m)
|
| 46 |
|
| 47 |
def main():
|
| 48 |
st.sidebar.title("Navigation")
|
| 49 |
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Localisation des Entreprises"])
|
|
|
|
| 50 |
data = get_data()
|
|
|
|
| 51 |
if app_mode == "Organisations engagées":
|
| 52 |
display_organisations_engagees(data)
|
| 53 |
elif app_mode == "Localisation des Entreprises":
|