Commit
·
c823b3c
1
Parent(s):
c947a73
Pytorch V0.9
Browse files
app.py
CHANGED
|
@@ -9,17 +9,14 @@ def get_data():
|
|
| 9 |
response = requests.get(url)
|
| 10 |
if response.status_code == 200:
|
| 11 |
data = response.json()
|
| 12 |
-
records = data
|
| 13 |
-
|
| 14 |
for record in records:
|
| 15 |
-
|
| 16 |
-
#
|
| 17 |
-
if
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
field["longitude"] = lon
|
| 21 |
-
data_for_display.append(field)
|
| 22 |
-
return data_for_display
|
| 23 |
else:
|
| 24 |
return []
|
| 25 |
|
|
@@ -27,24 +24,29 @@ def display_organisations_engagees(data):
|
|
| 27 |
st.markdown("## OPEN DATA RSE")
|
| 28 |
st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
def display_map(data):
|
| 41 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
| 42 |
for item in data:
|
| 43 |
-
|
|
|
|
| 44 |
folium.Marker(
|
| 45 |
-
[
|
| 46 |
icon=folium.Icon(color="green", icon="leaf"),
|
| 47 |
-
popup=item
|
| 48 |
).add_to(m)
|
| 49 |
folium_static(m)
|
| 50 |
|
|
|
|
| 9 |
response = requests.get(url)
|
| 10 |
if response.status_code == 200:
|
| 11 |
data = response.json()
|
| 12 |
+
records = data.get("records", [])
|
| 13 |
+
cleaned_data = []
|
| 14 |
for record in records:
|
| 15 |
+
fields = record.get("fields", {})
|
| 16 |
+
# Assurez-vous que les champs nécessaires existent
|
| 17 |
+
if all(key in fields for key in ['nom_courant_denomination', 'commune', 'libelle_section_naf', 'tranche_effectif_entreprise', 'action_rse']):
|
| 18 |
+
cleaned_data.append(fields)
|
| 19 |
+
return cleaned_data
|
|
|
|
|
|
|
|
|
|
| 20 |
else:
|
| 21 |
return []
|
| 22 |
|
|
|
|
| 24 |
st.markdown("## OPEN DATA RSE")
|
| 25 |
st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
|
| 26 |
|
| 27 |
+
if data:
|
| 28 |
+
df = pd.DataFrame(data)
|
| 29 |
+
df = df[['nom_courant_denomination', 'commune', 'libelle_section_naf', 'tranche_effectif_entreprise', 'action_rse']]
|
| 30 |
+
df.rename(columns={
|
| 31 |
+
'nom_courant_denomination': 'Nom',
|
| 32 |
+
'commune': 'Commune',
|
| 33 |
+
'libelle_section_naf': 'Section NAF',
|
| 34 |
+
'tranche_effectif_entreprise': 'Effectif',
|
| 35 |
+
'action_rse': 'Action RSE'
|
| 36 |
+
}, inplace=True)
|
| 37 |
+
st.dataframe(df)
|
| 38 |
+
else:
|
| 39 |
+
st.write("Aucune donnée disponible.")
|
| 40 |
|
| 41 |
def display_map(data):
|
| 42 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
| 43 |
for item in data:
|
| 44 |
+
geoloc = item.get('geolocalisation')
|
| 45 |
+
if geoloc:
|
| 46 |
folium.Marker(
|
| 47 |
+
location=[geoloc[0], geoloc[1]],
|
| 48 |
icon=folium.Icon(color="green", icon="leaf"),
|
| 49 |
+
popup=item.get('nom_courant_denomination', 'Information non disponible'),
|
| 50 |
).add_to(m)
|
| 51 |
folium_static(m)
|
| 52 |
|