KeshavRa commited on
Commit
6c6ae46
·
verified ·
1 Parent(s): c8ebc0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -160,17 +160,18 @@ else:
160
  shelters = shelters[(shelters['Domestic Violence'] == "No")]
161
 
162
  # calculate distances between zipcodes
163
- geocoding_api_key = os.environ['OpenWeather_API_KEY']
 
 
 
 
164
 
165
- shelters_coordinates = shelters.apply(lambda row: get_coordinates(row['Zip Code'], geocoding_api_key), axis=1).tolist()
166
- user_coordinates = get_coordinates(data['Zip Code'], geocoding_api_key)
167
-
168
- distances = []
169
- for coordinates in shelters_coordinates:
170
- distances.append(haversine(coordinates[0], coordinates[1], user_coordinates[0], user_coordinates[1]))
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()