Commit
·
af7ba50
1
Parent(s):
bb3771a
Pytorch V0.6
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import requests
|
|
@@ -10,23 +11,23 @@ def get_data():
|
|
| 10 |
if response.status_code == 200:
|
| 11 |
data = response.json()
|
| 12 |
records = data["records"]
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
return []
|
| 15 |
|
| 16 |
def display_organisations_engagees(data):
|
| 17 |
st.markdown("## OPEN DATA RSE")
|
| 18 |
st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
|
| 19 |
-
|
| 20 |
df = pd.DataFrame(data)
|
| 21 |
if not df.empty:
|
| 22 |
-
df = df.rename(columns={
|
| 23 |
-
"nom_courant_denomination": "Nom",
|
| 24 |
-
"commune": "Commune",
|
| 25 |
-
"libelle_section_naf": "Section NAF",
|
| 26 |
-
"tranche_effectif_entreprise": "Effectif",
|
| 27 |
-
"action_rse": "Action RSE"
|
| 28 |
-
})
|
| 29 |
-
df = df[["Nom", "Commune", "Section NAF", "Effectif", "Action RSE"]]
|
| 30 |
st.dataframe(df)
|
| 31 |
else:
|
| 32 |
st.write("Aucune donnée disponible.")
|
|
@@ -34,12 +35,11 @@ def display_organisations_engagees(data):
|
|
| 34 |
def display_map(data):
|
| 35 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
| 36 |
for item in data:
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
).add_to(m)
|
| 43 |
folium_static(m)
|
| 44 |
|
| 45 |
def main():
|
|
|
|
| 1 |
+
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
import requests
|
|
|
|
| 11 |
if response.status_code == 200:
|
| 12 |
data = response.json()
|
| 13 |
records = data["records"]
|
| 14 |
+
data_for_map = []
|
| 15 |
+
for record in records:
|
| 16 |
+
fields = record.get("fields", {})
|
| 17 |
+
geo = fields.get("geolocalisation")
|
| 18 |
+
if geo and len(geo) == 2:
|
| 19 |
+
lat, lon = geo
|
| 20 |
+
fields["latitude"] = lat
|
| 21 |
+
fields["longitude"] = lon
|
| 22 |
+
data_for_map.append(fields)
|
| 23 |
+
return data_for_map
|
| 24 |
return []
|
| 25 |
|
| 26 |
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 |
df = pd.DataFrame(data)
|
| 30 |
if not df.empty:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
st.dataframe(df)
|
| 32 |
else:
|
| 33 |
st.write("Aucune donnée disponible.")
|
|
|
|
| 35 |
def display_map(data):
|
| 36 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
| 37 |
for item in data:
|
| 38 |
+
folium.Marker(
|
| 39 |
+
[item['latitude'], item['longitude']],
|
| 40 |
+
icon=folium.Icon(color="green", icon="leaf"),
|
| 41 |
+
popup=item.get('nom_courant_denomination', 'Sans nom'),
|
| 42 |
+
).add_to(m)
|
|
|
|
| 43 |
folium_static(m)
|
| 44 |
|
| 45 |
def main():
|