nastasiasnk commited on
Commit
a173230
1 Parent(s): 980735d

Update imports_utils.py

Browse files
Files changed (1) hide show
  1. imports_utils.py +37 -0
imports_utils.py CHANGED
@@ -307,4 +307,41 @@ def remap(value, B_min, B_max, C_min, C_max):
307
 
308
 
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
 
 
307
 
308
 
309
 
310
+ def accessibilityToLivability (DistanceMatrix,accessibilityInputs, SubdomainAttributeDict,UniqueDomainsList):
311
+ livability = pd.DataFrame(index=DistanceMatrix.index, columns=accessibilityInputs.columns)
312
+
313
+ for domain in UniqueDomainsList:
314
+ livability[domain] = 0
315
+
316
+ livability.fillna(0, inplace=True)
317
+ templist = []
318
+ # remap accessibility to livability points
319
+
320
+ for key, values in SubdomainAttributeDict.items():
321
+ threshold = float(SubdomainAttributeDict[key]['thresholds'])
322
+ max_livability = float(SubdomainAttributeDict[key]['max_points'])
323
+ domains = [str(item) for item in SubdomainAttributeDict[key]['domain']]
324
+
325
+ if key in accessibilityInputs.columns and key != 'commercial':
326
+ livability_score = remap(accessibilityInputs[key], 0, threshold, 0, max_livability)
327
+ livability.loc[accessibilityInputs[key] >= threshold, key] = max_livability
328
+ livability.loc[accessibilityInputs[key] < threshold, key] = livability_score
329
+ if any(domains):
330
+ for domain in domains:
331
+ if domain != 'Workplaces':
332
+ livability.loc[accessibilityInputs[key] >= threshold, domain] += max_livability
333
+ livability.loc[accessibilityInputs[key] < threshold, domain] += livability_score
334
+
335
+ elif key == 'commercial':
336
+ livability_score = remap(accessibilityInputs['jobs'], 0, threshold, 0, max_livability)
337
+ livability.loc[accessibilityInputs['jobs'] >= threshold, domains[0]] = max_livability
338
+ livability.loc[accessibilityInputs['jobs'] < threshold, domains[0]] = livability_score
339
+
340
+
341
+ return livability
342
+
343
+
344
+
345
+
346
+
347