LaurentTRIPIED commited on
Commit
e7aad60
1 Parent(s): b9b1499

Pytorch V0.8

Browse files
Files changed (1) hide show
  1. app.py +10 -19
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["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
 
@@ -29,24 +20,24 @@ def display_organisations_engagees(data):
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
 
 
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