Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
•
456badc
1
Parent(s):
0f24534
filter nans
Browse files- app.py +2 -3
- src/dataframes.py +1 -1
- 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,
|
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
|
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 = "
|
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[
|
38 |
is_future_intervention = (
|
39 |
-
row[interventions_df.columns[
|
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 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
<b>Population:</b> {population}<br>
|
76 |
-
<b>
|
77 |
-
<b>
|
78 |
-
|
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=
|
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 |
)
|