nouamanetazi HF staff commited on
Commit
456badc
1 Parent(s): 0f24534

filter nans

Browse files
Files changed (3) hide show
  1. app.py +2 -3
  2. src/dataframes.py +1 -1
  3. src/markers.py +52 -21
app.py CHANGED
@@ -7,7 +7,7 @@ import folium
7
  import streamlit as st
8
  from huggingface_hub import HfApi
9
  from streamlit_folium import st_folium
10
- from src.components import show_dataframes_metrics, show_embed_code, id_review_submission, show_donations
11
  from src.text_content import (
12
  CREDITS_TEXT,
13
  LOGO,
@@ -15,8 +15,7 @@ from src.text_content import (
15
  )
16
  from src.utils import init_map
17
  from src.map_utils import get_legend_macro
18
- from src.dataframes import display_dataframe
19
- from src.dataframes import load_data, VERIFIED_REQUESTS_URL, REQUESTS_URL, INTERVENTIONS_URL
20
  import gettext
21
 
22
  gettext.install("myapplication")
 
7
  import streamlit as st
8
  from huggingface_hub import HfApi
9
  from streamlit_folium import st_folium
10
+ from src.components import show_dataframes_metrics, show_embed_code, show_donations
11
  from src.text_content import (
12
  CREDITS_TEXT,
13
  LOGO,
 
15
  )
16
  from src.utils import init_map
17
  from src.map_utils import get_legend_macro
18
+ from src.dataframes import load_data
 
19
  import gettext
20
 
21
  gettext.install("myapplication")
src/dataframes.py CHANGED
@@ -91,7 +91,7 @@ def display_dataframe(df, drop_cols, data_url, search_id=True, status=False, for
91
  display_df = display_df.drop(drop_cols, axis=1)
92
 
93
  if status:
94
- target = "Pouvez-vous nous préciser si vous êtes déjà intervenus ou si vous prévoyez de le faire | Tell us if you already made the intervention, or if you're planning to do it"
95
  if selected_status == "Done / تم":
96
  display_df = display_df[display_df[target] == "Intervention déjà passée / Past intevention"]
97
 
 
91
  display_df = display_df.drop(drop_cols, axis=1)
92
 
93
  if status:
94
+ target = "Intervention status"
95
  if selected_status == "Done / تم":
96
  display_df = display_df[display_df[target] == "Intervention déjà passée / Past intevention"]
97
 
src/markers.py CHANGED
@@ -18,6 +18,7 @@ ICON_MAPPING = {
18
  "طعام وماء": "cutlery", # cutlery (fork and knife) for food & water
19
  "مخاطر (تسرب الغاز، تلف في الخدمات العامة...)": "Warning" # warning triangle for dangers
20
  }
 
21
 
22
  def marker_request(request):
23
  # in case of multiple requests we use the first one for the marker's icon
@@ -34,9 +35,9 @@ def display_interventions(interventions_df, selected_statuses, map_obj, interven
34
  """Display NGO interventions on the map"""
35
 
36
  for index, row in interventions_df.iterrows():
37
- village_status = row[interventions_df.columns[7]]
38
  is_future_intervention = (
39
- row[interventions_df.columns[5]] == "Intervention prévue dans le futur / Planned future intervention"
40
  )
41
 
42
  if pd.isna(village_status) and not is_future_intervention:
@@ -57,27 +58,57 @@ def display_interventions(interventions_df, selected_statuses, map_obj, interven
57
  color_mk = "darkgreen"
58
  status = "Partial 📝"
59
 
60
- intervention_type = row[interventions_df.columns[6]]
61
- org = row[interventions_df.columns[1]]
62
- contact = row[interventions_df.columns[2]]
63
- city = row[interventions_df.columns[9]]
64
- date = row[interventions_df.columns[4]]
65
- population = row[interventions_df.columns[11]]
66
- details = row[interventions_df.columns[8]]
67
- road_state = row[interventions_df.columns[12]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  intervention_info = f"""
69
- <b>Date:</b> {date}<br>
70
- <b>City:</b> {city}<br>
71
- <b>Intervention Status:</b> {status}<br>
72
- <b>Village Status:</b> {village_status}<br>
73
  <b>Org:</b> {org}<br>
74
- <b>Intervention:</b> {intervention_type}<br>
 
 
 
 
 
 
 
 
 
 
 
 
75
  <b>Population:</b> {population}<br>
76
- <b>Road State:</b> {road_state}<br>
77
- <b>Details:</b> {details}<br>
78
- <b>Contact:</b> {contact}<br>
79
- """
80
-
81
  if row["latlng"] is None:
82
  continue
83
 
@@ -85,7 +116,7 @@ def display_interventions(interventions_df, selected_statuses, map_obj, interven
85
  fg.add_child(
86
  folium.Marker(
87
  location=row["latlng"],
88
- tooltip=city,
89
  popup=folium.Popup(intervention_info, max_width=300),
90
  icon=folium.Icon(color=color_mk),
91
  )
 
18
  "طعام وماء": "cutlery", # cutlery (fork and knife) for food & water
19
  "مخاطر (تسرب الغاز، تلف في الخدمات العامة...)": "Warning" # warning triangle for dangers
20
  }
21
+ numcol = lambda x: ord(x) - ord("A")
22
 
23
  def marker_request(request):
24
  # in case of multiple requests we use the first one for the marker's icon
 
35
  """Display NGO interventions on the map"""
36
 
37
  for index, row in interventions_df.iterrows():
38
+ village_status = row[interventions_df.columns[numcol("K")]]
39
  is_future_intervention = (
40
+ row[interventions_df.columns[numcol("H")]] == "Intervention prévue dans le futur / Planned future intervention"
41
  )
42
 
43
  if pd.isna(village_status) and not is_future_intervention:
 
58
  color_mk = "darkgreen"
59
  status = "Partial 📝"
60
 
61
+ # ['Horodateur', 'Organization Name', 'Association ID', 'Speciality',
62
+ # 'Phone 1', 'Phone 2', 'Email', 'Intervention status',
63
+ # 'Intervention date', 'Types of Help Provided',
64
+ # 'Current situation of the area', 'Future help type', 'Douar name',
65
+ # 'Commune', 'Caidat', ' Google Maps Link',
66
+ # 'Accessibility to the targeted douar', 'Type of accessibility',
67
+ # 'Population of the douar if available', 'Intervention Additional Info',
68
+ # 'Any Additional info is welcome', 'Automatic Extracted Coordinates',
69
+ # 'Unnamed: 22'],
70
+
71
+ org = row[interventions_df.columns[numcol("B")]]
72
+ association_id = row[interventions_df.columns[numcol("C")]]
73
+ speciality = row[interventions_df.columns[numcol("D")]]
74
+ phone_1 = row[interventions_df.columns[numcol("E")]]
75
+ phone_2 = row[interventions_df.columns[numcol("F")]]
76
+ email = row[interventions_df.columns[numcol("G")]]
77
+ intervention_status = row[interventions_df.columns[numcol("H")]]
78
+ intervention_date = row[interventions_df.columns[numcol("I")]]
79
+ help_type = row[interventions_df.columns[numcol("J")]]
80
+ current_situation = row[interventions_df.columns[numcol("K")]]
81
+ future_help_type = row[interventions_df.columns[numcol("L")]]
82
+ douar_name = row[interventions_df.columns[numcol("M")]]
83
+ commune = row[interventions_df.columns[numcol("N")]]
84
+ caidat = row[interventions_df.columns[numcol("O")]]
85
+ google_maps_link = row[interventions_df.columns[numcol("P")]]
86
+ accessibility_to_douar = row[interventions_df.columns[numcol("Q")]]
87
+ type_of_accessibility = row[interventions_df.columns[numcol("R")]]
88
+ population = row[interventions_df.columns[numcol("S")]]
89
+ intervention_additional_info = row[interventions_df.columns[numcol("T")]]
90
+ any_additional_info = row[interventions_df.columns[numcol("U")]]
91
+
92
+ full_douar_name = ", ".join([x for x in [douar_name, commune, caidat] if not pd.isna(x)])
93
  intervention_info = f"""
 
 
 
 
94
  <b>Org:</b> {org}<br>
95
+ <b>Association ID:</b> {association_id}<br>
96
+ <b>Speciality:</b> {speciality}<br>
97
+ <b>Phone 1:</b> {phone_1}<br>
98
+ <b>Phone 2:</b> {phone_2}<br>
99
+ <b>Email:</b> {email}<br>
100
+ <b>Intervention Date:</b> {intervention_date}<br>
101
+ <b>Intervention Status:</b> {intervention_status}<br>
102
+ <b>Help Type:</b> {help_type}<br>
103
+ <b>Current Situation:</b> {current_situation}<br>
104
+ <b>Future Help Type:</b> {future_help_type}<br>
105
+ <b>Douar Name:</b> {full_douar_name}<br>
106
+ <b>Accessibility to Douar:</b> {accessibility_to_douar}<br>
107
+ <b>Type of Accessibility:</b> {type_of_accessibility}<br>
108
  <b>Population:</b> {population}<br>
109
+ <b>Intervention Additional Info:</b> {intervention_additional_info}<br>
110
+ <b>Any Additional Info:</b> {any_additional_info}<br>
111
+ """ #TODO: filter nans
 
 
112
  if row["latlng"] is None:
113
  continue
114
 
 
116
  fg.add_child(
117
  folium.Marker(
118
  location=row["latlng"],
119
+ tooltip=full_douar_name,
120
  popup=folium.Popup(intervention_info, max_width=300),
121
  icon=folium.Icon(color=color_mk),
122
  )