LaurentTRIPIED commited on
Commit
f8cfe0e
1 Parent(s): 2c9e460

Pytorch V0.9

Browse files
Files changed (1) hide show
  1. app.py +24 -22
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["records"]
13
- data_for_display = []
14
  for record in records:
15
- field = record["fields"]
16
- # Assume that 'geolocalisation' field is present and correctly formatted
17
- if "geolocalisation" in field:
18
- lat, lon = field["geolocalisation"]
19
- field["latitude"] = lat
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
- df = pd.DataFrame(data)
31
- df = df[['nom_courant_denomination', 'commune', 'libelle_section_naf', 'tranche_effectif_entreprise', 'action_rse']]
32
- st.dataframe(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
 
40
  def display_map(data):
41
  m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
42
  for item in data:
43
- if 'latitude' in item and 'longitude' in item:
 
44
  folium.Marker(
45
- [item['latitude'], item['longitude']],
46
  icon=folium.Icon(color="green", icon="leaf"),
47
- popup=item['nom_courant_denomination'],
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