Commit
·
53d20c5
1
Parent(s):
37f612f
Pytorch V0.8
Browse files
app.py
CHANGED
|
@@ -9,17 +9,8 @@ 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 |
-
fields = record["fields"]
|
| 16 |
-
geoloc = fields.get('geolocalisation')
|
| 17 |
-
if geoloc and len(geoloc) == 2:
|
| 18 |
-
# Ajoutez latitude et longitude directement aux champs pour faciliter l'accès
|
| 19 |
-
fields['latitude'] = geoloc[0]
|
| 20 |
-
fields['longitude'] = geoloc[1]
|
| 21 |
-
cleaned_data.append(fields)
|
| 22 |
-
return cleaned_data
|
| 23 |
else:
|
| 24 |
return []
|
| 25 |
|
|
@@ -29,24 +20,24 @@ def display_organisations_engagees(data):
|
|
| 29 |
|
| 30 |
df = pd.DataFrame(data)
|
| 31 |
if not df.empty:
|
| 32 |
-
df = df
|
|
|
|
| 33 |
"nom_courant_denomination": "Nom",
|
| 34 |
"commune": "Commune",
|
| 35 |
"libelle_section_naf": "Section NAF",
|
| 36 |
"tranche_effectif_entreprise": "Effectif",
|
| 37 |
"action_rse": "Action RSE"
|
| 38 |
-
})
|
| 39 |
-
df = df[["Nom", "Commune", "Section NAF", "Effectif", "Action RSE"]]
|
| 40 |
-
st.dataframe(df)
|
| 41 |
|
| 42 |
def display_map(data):
|
| 43 |
-
|
|
|
|
| 44 |
for item in data:
|
| 45 |
-
if
|
| 46 |
folium.Marker(
|
| 47 |
-
[item[
|
|
|
|
| 48 |
icon=folium.Icon(color="green", icon="leaf"),
|
| 49 |
-
popup=item.get('nom_courant_denomination', 'Sans nom'),
|
| 50 |
).add_to(m)
|
| 51 |
folium_static(m)
|
| 52 |
|
|
|
|
| 9 |
response = requests.get(url)
|
| 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 |
|
|
|
|
| 20 |
|
| 21 |
df = pd.DataFrame(data)
|
| 22 |
if not df.empty:
|
| 23 |
+
df = df[["nom_courant_denomination", "commune", "libelle_section_naf", "tranche_effectif_entreprise", "action_rse"]]
|
| 24 |
+
st.dataframe(df.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 |
+
bordeaux_loc = [44.837789, -0.57918]
|
| 34 |
+
m = folium.Map(location=bordeaux_loc, zoom_start=12)
|
| 35 |
for item in data:
|
| 36 |
+
if item.get("geolocalisation"):
|
| 37 |
folium.Marker(
|
| 38 |
+
location=[item["geolocalisation"][0], item["geolocalisation"][1]],
|
| 39 |
+
popup=item.get("nom_courant_denomination", "Information non disponible"),
|
| 40 |
icon=folium.Icon(color="green", icon="leaf"),
|
|
|
|
| 41 |
).add_to(m)
|
| 42 |
folium_static(m)
|
| 43 |
|