loubnabnl HF staff commited on
Commit
eac7583
1 Parent(s): 9150d37

add utility functions

Browse files
Files changed (1) hide show
  1. src/utils.py +20 -13
src/utils.py CHANGED
@@ -12,19 +12,26 @@ def parse_gg_sheet(url):
12
  df = pd.read_csv(url, on_bad_lines="warn")
13
  return df
14
 
15
- # Session for Requests
16
- # session = requests.Session()
17
- # @st.cache_data(persist=True)
18
- # def parse_latlng_from_link(url):
19
- # try:
20
- # # extract latitude and longitude from gmaps link
21
- # if "@" not in url:
22
- # resp = session.head(url, allow_redirects=True)
23
- # url = resp.url
24
- # latlng = url.split("@")[1].split(",")[0:2]
25
- # return [float(latlng[0]), float(latlng[1])]
26
- # except Exception as e:
27
- # return None
 
 
 
 
 
 
 
28
 
29
  def add_latlng_col(df, process_column):
30
  """Add a latlng column to the dataframe"""
 
12
  df = pd.read_csv(url, on_bad_lines="warn")
13
  return df
14
 
15
+
16
+ def is_request_in_list(request, selection_list):
17
+ if isinstance(request, float): # Check if the input is a float (like NaN)
18
+ return False
19
+ if "," in request:
20
+ all_requests = [r.strip() for r in request.split(",")]
21
+ else:
22
+ all_requests = [request]
23
+ return any([r in selection_list for r in all_requests])
24
+
25
+
26
+ def marker_request(request):
27
+ # in case of multiple requests we use the first one for the marker's icon
28
+ # requests are already sorted by priority from the form
29
+ try:
30
+ displayed_request = request.split(',')[0]
31
+ except:
32
+ displayed_request = request
33
+ return displayed_request
34
+
35
 
36
  def add_latlng_col(df, process_column):
37
  """Add a latlng column to the dataframe"""