nastasiasnk commited on
Commit
a0d7355
·
verified ·
1 Parent(s): 6eedbd5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -219,13 +219,14 @@ def test(input_json):
219
  livability = pd.DataFrame(index=DistanceMatrix.index, columns=subdomainsAccessibility.columns)
220
  #livability.drop(columns='jobs', inplace=True)
221
  #livability["Workplaces"] = 0
222
- livability.fillna(0, inplace=True)
223
-
224
-
225
  for domain in UniqueDomainsList:
226
  livability[domain] = 0
 
 
227
 
228
- livability.drop(columns='Workplaces', inplace=True)
 
229
 
230
  # remap accessibility to livability points
231
 
@@ -233,23 +234,24 @@ def test(input_json):
233
  threshold = float(SubdomainAttributeDict[key]['thresholds'])
234
  max_livability = float(SubdomainAttributeDict[key]['max_points'])
235
  domain = [str(item) for item in SubdomainAttributeDict[key]['domain']]
236
- """
237
  if key == 'commercial':
238
  livability_score = remap(subdomainsAccessibility['jobs'], 0, threshold, 0, max_livability)
239
  livability.loc[subdomainsAccessibility['jobs'] >= threshold, 'Workplaces'] = max_livability
240
  livability.loc[subdomainsAccessibility['jobs'] < threshold, 'Workplaces'] = livability_score
241
- """
242
  if key in subdomainsAccessibility.columns:
243
  livability_score = remap(subdomainsAccessibility[key], 0, threshold, 0, max_livability)
244
  livability.loc[subdomainsAccessibility[key] >= threshold, key] = max_livability
245
  livability.loc[subdomainsAccessibility[key] < threshold, key] = livability_score
246
  if any(domain):
247
  for item in domain:
248
- livability.loc[subdomainsAccessibility[key] >= threshold, item] += max_livability
249
- livability.loc[subdomainsAccessibility[key] < threshold, item] += livability_score
 
250
 
251
 
252
- livability = livability.rename(columns={'jobs': 'Workplaces'})
253
 
254
  return livability
255
 
 
219
  livability = pd.DataFrame(index=DistanceMatrix.index, columns=subdomainsAccessibility.columns)
220
  #livability.drop(columns='jobs', inplace=True)
221
  #livability["Workplaces"] = 0
222
+
 
 
223
  for domain in UniqueDomainsList:
224
  livability[domain] = 0
225
+
226
+ livability.fillna(0, inplace=True)
227
 
228
+ #livability.drop(columns='Workplaces', inplace=True)
229
+
230
 
231
  # remap accessibility to livability points
232
 
 
234
  threshold = float(SubdomainAttributeDict[key]['thresholds'])
235
  max_livability = float(SubdomainAttributeDict[key]['max_points'])
236
  domain = [str(item) for item in SubdomainAttributeDict[key]['domain']]
237
+
238
  if key == 'commercial':
239
  livability_score = remap(subdomainsAccessibility['jobs'], 0, threshold, 0, max_livability)
240
  livability.loc[subdomainsAccessibility['jobs'] >= threshold, 'Workplaces'] = max_livability
241
  livability.loc[subdomainsAccessibility['jobs'] < threshold, 'Workplaces'] = livability_score
242
+
243
  if key in subdomainsAccessibility.columns:
244
  livability_score = remap(subdomainsAccessibility[key], 0, threshold, 0, max_livability)
245
  livability.loc[subdomainsAccessibility[key] >= threshold, key] = max_livability
246
  livability.loc[subdomainsAccessibility[key] < threshold, key] = livability_score
247
  if any(domain):
248
  for item in domain:
249
+ if domain != 'Workplaces':
250
+ livability.loc[subdomainsAccessibility[key] >= threshold, item] += max_livability
251
+ livability.loc[subdomainsAccessibility[key] < threshold, item] += livability_score
252
 
253
 
254
+ #livability = livability.rename(columns={'jobs': 'Workplaces'})
255
 
256
  return livability
257