Spaces:
Sleeping
Sleeping
nastasiasnk
commited on
Commit
•
fbce734
1
Parent(s):
a68aa72
Update app.py
Browse files
app.py
CHANGED
@@ -217,36 +217,22 @@ def test(input_json):
|
|
217 |
|
218 |
|
219 |
from imports_utils import landusesToSubdomains
|
220 |
-
|
221 |
-
"""
|
222 |
-
def landusesToSubdomains(DistanceMatrix, LanduseDf, LanduseToSubdomainDict, UniqueSubdomainsList):
|
223 |
-
df_LivabilitySubdomainsArea = pd.DataFrame(0, index=DistanceMatrix.index, columns=UniqueSubdomainsList)
|
224 |
|
225 |
-
for subdomain in UniqueSubdomainsList:
|
226 |
-
for lu, lu_subdomain in LanduseToSubdomainDict.items():
|
227 |
-
if lu_subdomain == subdomain:
|
228 |
-
if lu in LanduseDf.columns:
|
229 |
-
df_LivabilitySubdomainsArea[subdomain] = df_LivabilitySubdomainsArea[subdomain].add(LanduseDf[lu], fill_value=0)
|
230 |
-
else:
|
231 |
-
print(f"Warning: Column '{lu}' not found in landuse database")
|
232 |
-
|
233 |
-
return df_LivabilitySubdomainsArea
|
234 |
|
235 |
-
|
236 |
-
"""
|
237 |
LivabilitySubdomainsWeights = landusesToSubdomains(df_dm,df_landuses_filtered,landuseMapperDict,subdomainsUnique)
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
-
|
243 |
-
def
|
244 |
|
245 |
df_LivabilitySubdomainsWorkplaces = pd.DataFrame(0, index=DistanceMatrix.index, columns=['jobs'])
|
246 |
|
247 |
for subdomain in UniqueSubdomainsList:
|
248 |
for key, value_list in SubdomainAttributeDict.items():
|
249 |
-
sqm_per_empl = float(SubdomainAttributeDict[subdomain]['sqmPerEmpl'])
|
250 |
if key in destinationWeights.columns and key == subdomain:
|
251 |
if sqm_per_empl > 0:
|
252 |
df_LivabilitySubdomainsWorkplaces['jobs'] += (round(destinationWeights[key] / sqm_per_empl,2)).fillna(0)
|
@@ -255,8 +241,8 @@ def test(input_json):
|
|
255 |
|
256 |
return df_LivabilitySubdomainsWorkplaces
|
257 |
|
258 |
-
|
259 |
-
WorkplacesNumber =
|
260 |
|
261 |
# prepare an input weights dataframe for the parameter LivabilitySubdomainsInputs
|
262 |
LivabilitySubdomainsInputs =pd.concat([LivabilitySubdomainsWeights, WorkplacesNumber], axis=1)
|
|
|
217 |
|
218 |
|
219 |
from imports_utils import landusesToSubdomains
|
220 |
+
from imports_utils import FindWorkplacesNumber
|
|
|
|
|
|
|
221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
|
|
|
|
|
223 |
LivabilitySubdomainsWeights = landusesToSubdomains(df_dm,df_landuses_filtered,landuseMapperDict,subdomainsUnique)
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
+
"""
|
229 |
+
def FindWorkplacesNumber (DistanceMatrix,SubdomainAttributeDict,destinationWeights,UniqueSubdomainsList ):
|
230 |
|
231 |
df_LivabilitySubdomainsWorkplaces = pd.DataFrame(0, index=DistanceMatrix.index, columns=['jobs'])
|
232 |
|
233 |
for subdomain in UniqueSubdomainsList:
|
234 |
for key, value_list in SubdomainAttributeDict.items():
|
235 |
+
sqm_per_empl = float(SubdomainAttributeDict[subdomain]['sqmPerEmpl'])
|
236 |
if key in destinationWeights.columns and key == subdomain:
|
237 |
if sqm_per_empl > 0:
|
238 |
df_LivabilitySubdomainsWorkplaces['jobs'] += (round(destinationWeights[key] / sqm_per_empl,2)).fillna(0)
|
|
|
241 |
|
242 |
return df_LivabilitySubdomainsWorkplaces
|
243 |
|
244 |
+
"""
|
245 |
+
WorkplacesNumber = FindWorkplacesNumber(df_dm,attributeMapperDict,LivabilitySubdomainsWeights,subdomainsUnique)
|
246 |
|
247 |
# prepare an input weights dataframe for the parameter LivabilitySubdomainsInputs
|
248 |
LivabilitySubdomainsInputs =pd.concat([LivabilitySubdomainsWeights, WorkplacesNumber], axis=1)
|