Spaces:
Running
Running
LaurentTRIPIED
commited on
Commit
•
b9b1499
1
Parent(s):
abafa2a
Pytorch V0.7
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
import streamlit as st
|
3 |
import pandas as pd
|
4 |
import requests
|
@@ -11,35 +10,44 @@ def get_data():
|
|
11 |
if response.status_code == 200:
|
12 |
data = response.json()
|
13 |
records = data["records"]
|
14 |
-
|
15 |
for record in records:
|
16 |
-
fields = record
|
17 |
-
|
18 |
-
if
|
19 |
-
|
20 |
-
fields[
|
21 |
-
fields[
|
22 |
-
|
23 |
-
return
|
24 |
-
|
|
|
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.")
|
34 |
|
35 |
def display_map(data):
|
36 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
37 |
for item in data:
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
43 |
folium_static(m)
|
44 |
|
45 |
def main():
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import requests
|
|
|
10 |
if response.status_code == 200:
|
11 |
data = response.json()
|
12 |
records = data["records"]
|
13 |
+
cleaned_data = []
|
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 |
|
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 |
+
|
30 |
df = pd.DataFrame(data)
|
31 |
if not df.empty:
|
32 |
+
df = df.rename(columns={
|
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 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
44 |
for item in data:
|
45 |
+
if 'latitude' in item and 'longitude' in item:
|
46 |
+
folium.Marker(
|
47 |
+
[item['latitude'], item['longitude']],
|
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 |
|
53 |
def main():
|