Spaces:
Sleeping
Sleeping
nastasiasnk
commited on
Commit
•
cd11506
1
Parent(s):
aebe9d6
Update app.py
Browse files
app.py
CHANGED
@@ -62,49 +62,49 @@ def test(input_json):
|
|
62 |
|
63 |
def accessibilityToLivability (DistanceMatrix,subdomainsAccessibility, SubdomainAttributeDict):
|
64 |
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
-
# find a set of unique domains, to which subdomains are aggregated
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
for key, values in SubdomainAttributeDict.items():
|
73 |
-
domain = SubdomainAttributeDict[key]['domain']
|
74 |
-
for item in domain:
|
75 |
-
if ',' in item:
|
76 |
-
domain_list = item.split(',')
|
77 |
-
SubdomainAttributeDict[key]['domain'] = domain_list
|
78 |
-
for domain in domain_list:
|
79 |
-
temp.append(domain)
|
80 |
-
else:
|
81 |
-
if item != 0:
|
82 |
-
temp.append(item)
|
83 |
-
|
84 |
-
domainsUnique = list(set(temp))
|
85 |
-
|
86 |
-
for domain in domainsUnique:
|
87 |
-
livability[domain] = 0
|
88 |
-
|
89 |
-
|
90 |
-
# remap accessibility to livability points
|
91 |
-
|
92 |
-
for key, values in SubdomainAttributeDict.items():
|
93 |
-
threshold = float(SubdomainAttributeDict[key]['thresholds'])
|
94 |
-
max_livability = float(SubdomainAttributeDict[key]['max_points'])
|
95 |
-
domain = SubdomainAttributeDict[key]['domain']
|
96 |
-
sqm_per_employee = str(SubdomainAttributeDict[key]['sqmPerEmpl'])
|
97 |
-
|
98 |
-
if key in subdomainsAccessibility.columns:
|
99 |
-
livability_score = remap(subdomainsAccessibility[key], 0, threshold, 0, max_livability)
|
100 |
-
livability.loc[subdomainsAccessibility[key] >= threshold, key] = max_livability
|
101 |
-
livability.loc[subdomainsAccessibility[key] < threshold, key] = livability_score
|
102 |
-
if any(domain):
|
103 |
-
for item in domain:
|
104 |
-
livability.loc[subdomainsAccessibility[key] >= threshold, domain] += max_livability
|
105 |
-
livability.loc[subdomainsAccessibility[key] < threshold, domain] += livability_score
|
106 |
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
|
110 |
|
|
|
62 |
|
63 |
def accessibilityToLivability (DistanceMatrix,subdomainsAccessibility, SubdomainAttributeDict):
|
64 |
|
65 |
+
livability = pd.DataFrame(index=DistanceMatrix.index, columns=subdomainsAccessibility.columns)
|
66 |
+
livability.fillna(0, inplace=True)
|
67 |
+
|
68 |
+
# find a set of unique domains, to which subdomains are aggregated
|
69 |
+
|
70 |
+
temp = []
|
71 |
+
|
72 |
+
for key, values in SubdomainAttributeDict.items():
|
73 |
+
domain = SubdomainAttributeDict[key]['domain']
|
74 |
+
for item in domain:
|
75 |
+
if ',' in item:
|
76 |
+
domain_list = item.split(',')
|
77 |
+
SubdomainAttributeDict[key]['domain'] = domain_list
|
78 |
+
for domain in domain_list:
|
79 |
+
temp.append(domain)
|
80 |
+
else:
|
81 |
+
if item != 0:
|
82 |
+
temp.append(item)
|
83 |
+
|
84 |
+
domainsUnique = list(set(temp))
|
85 |
+
|
86 |
+
for domain in domainsUnique:
|
87 |
+
livability[domain] = 0
|
88 |
|
|
|
89 |
|
90 |
+
# remap accessibility to livability points
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
+
for key, values in SubdomainAttributeDict.items():
|
93 |
+
threshold = float(SubdomainAttributeDict[key]['thresholds'])
|
94 |
+
max_livability = float(SubdomainAttributeDict[key]['max_points'])
|
95 |
+
domain = SubdomainAttributeDict[key]['domain']
|
96 |
+
sqm_per_employee = str(SubdomainAttributeDict[key]['sqmPerEmpl'])
|
97 |
+
|
98 |
+
if key in subdomainsAccessibility.columns:
|
99 |
+
livability_score = remap(subdomainsAccessibility[key], 0, threshold, 0, max_livability)
|
100 |
+
livability.loc[subdomainsAccessibility[key] >= threshold, key] = max_livability
|
101 |
+
livability.loc[subdomainsAccessibility[key] < threshold, key] = livability_score
|
102 |
+
if any(domain):
|
103 |
+
for item in domain:
|
104 |
+
livability.loc[subdomainsAccessibility[key] >= threshold, domain] += max_livability
|
105 |
+
livability.loc[subdomainsAccessibility[key] < threshold, domain] += livability_score
|
106 |
+
|
107 |
+
return livability
|
108 |
|
109 |
|
110 |
|