Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -160,17 +160,18 @@ else:
|
|
160 |
shelters = shelters[(shelters['Domestic Violence'] == "No")]
|
161 |
|
162 |
# calculate distances between zipcodes
|
163 |
-
|
|
|
|
|
|
|
|
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
max = max(distances) if (max(distances) != 0) else 1
|
173 |
-
shelters['zipcode_score'] = [d / max for d in distances]
|
174 |
|
175 |
# get urgency scores
|
176 |
urgency_scores = shelters.apply(lambda row: get_urgency_score(data['Urgency'], row['Urgency']), axis=1).tolist()
|
|
|
160 |
shelters = shelters[(shelters['Domestic Violence'] == "No")]
|
161 |
|
162 |
# calculate distances between zipcodes
|
163 |
+
if data['Zip Code'] != "Unsure":
|
164 |
+
geocoding_api_key = os.environ['OpenWeather_API_KEY']
|
165 |
+
|
166 |
+
shelters_coordinates = shelters.apply(lambda row: get_coordinates(row['Zip Code'], geocoding_api_key), axis=1).tolist()
|
167 |
+
user_coordinates = get_coordinates(data['Zip Code'], geocoding_api_key)
|
168 |
|
169 |
+
distances = []
|
170 |
+
for coordinates in shelters_coordinates:
|
171 |
+
distances.append(haversine(coordinates[0], coordinates[1], user_coordinates[0], user_coordinates[1]))
|
172 |
+
|
173 |
+
max = max(distances) if (max(distances) != 0) else 1
|
174 |
+
shelters['zipcode_score'] = [d / max for d in distances]
|
|
|
|
|
|
|
175 |
|
176 |
# get urgency scores
|
177 |
urgency_scores = shelters.apply(lambda row: get_urgency_score(data['Urgency'], row['Urgency']), axis=1).tolist()
|