Spaces:
Sleeping
Sleeping
nastasiasnk
commited on
Commit
•
6eedbd5
1
Parent(s):
0fc8c61
Update app.py
Browse files
app.py
CHANGED
@@ -217,40 +217,40 @@ def test(input_json):
|
|
217 |
def accessibilityToLivability (DistanceMatrix,subdomainsAccessibility, SubdomainAttributeDict,UniqueDomainsList):
|
218 |
|
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 |
|
229 |
# remap accessibility to livability points
|
230 |
|
231 |
for key, values in SubdomainAttributeDict.items():
|
|
|
|
|
|
|
|
|
232 |
if key == 'commercial':
|
233 |
-
threshold = float(SubdomainAttributeDict[key]['thresholds'])
|
234 |
-
max_livability = float(SubdomainAttributeDict[key]['max_points'])
|
235 |
livability_score = remap(subdomainsAccessibility['jobs'], 0, threshold, 0, max_livability)
|
236 |
livability.loc[subdomainsAccessibility['jobs'] >= threshold, 'Workplaces'] = max_livability
|
237 |
livability.loc[subdomainsAccessibility['jobs'] < threshold, 'Workplaces'] = livability_score
|
238 |
-
|
239 |
-
|
240 |
-
threshold = float(SubdomainAttributeDict[key]['thresholds'])
|
241 |
-
max_livability = float(SubdomainAttributeDict[key]['max_points'])
|
242 |
-
sqm_per_employee = SubdomainAttributeDict[key]['sqmPerEmpl']
|
243 |
-
|
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 |
-
|
250 |
-
|
251 |
-
livability.loc[subdomainsAccessibility[key] < threshold, item] += livability_score
|
252 |
|
253 |
|
|
|
|
|
254 |
return livability
|
255 |
|
256 |
|
|
|
217 |
def accessibilityToLivability (DistanceMatrix,subdomainsAccessibility, SubdomainAttributeDict,UniqueDomainsList):
|
218 |
|
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 |
|
232 |
for key, values in SubdomainAttributeDict.items():
|
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 |
|
256 |
|