Spaces:
Sleeping
Sleeping
Update imports_utils.py
Browse files- imports_utils.py +13 -0
imports_utils.py
CHANGED
@@ -335,6 +335,8 @@ def getDataFromGrasshopper(
|
|
335 |
dfMatrix_gh = dfMatrix_gh.apply(pd.to_numeric, errors='coerce')
|
336 |
dfMatrix_gh = dfMatrix_gh.replace([np.inf, -np.inf], 10000).fillna(0)
|
337 |
dfMatrix_gh = dfMatrix_gh.round(0).astype(int)
|
|
|
|
|
338 |
else:
|
339 |
dfMatrix_gh = None
|
340 |
|
@@ -344,6 +346,17 @@ def getDataFromGrasshopper(
|
|
344 |
dfLanduses_gh = dfLanduses_gh.apply(pd.to_numeric, errors='coerce')
|
345 |
dfLanduses_gh = dfLanduses_gh.replace([np.inf, -np.inf], 0).fillna(0) # cleaning function?
|
346 |
dfLanduses_gh = dfLanduses_gh.round(0).astype(int)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
else:
|
348 |
dfLanduses_gh = None
|
349 |
|
|
|
335 |
dfMatrix_gh = dfMatrix_gh.apply(pd.to_numeric, errors='coerce')
|
336 |
dfMatrix_gh = dfMatrix_gh.replace([np.inf, -np.inf], 10000).fillna(0)
|
337 |
dfMatrix_gh = dfMatrix_gh.round(0).astype(int)
|
338 |
+
|
339 |
+
mask_connected = dfMatrix_gh.index.tolist()
|
340 |
else:
|
341 |
dfMatrix_gh = None
|
342 |
|
|
|
346 |
dfLanduses_gh = dfLanduses_gh.apply(pd.to_numeric, errors='coerce')
|
347 |
dfLanduses_gh = dfLanduses_gh.replace([np.inf, -np.inf], 0).fillna(0) # cleaning function?
|
348 |
dfLanduses_gh = dfLanduses_gh.round(0).astype(int)
|
349 |
+
|
350 |
+
if dfMatrix_gh is not None:
|
351 |
+
valid_indexes = [idx for idx in mask_connected if idx in dfLanduses_gh.index]
|
352 |
+
# Identify and report missing indexes
|
353 |
+
missing_indexes = set(mask_connected) - set(valid_indexes)
|
354 |
+
if missing_indexes:
|
355 |
+
print(f"Error: The following indexes were not found in the DataFrame: {missing_indexes}, length: {len(missing_indexes)}")
|
356 |
+
|
357 |
+
# Apply the filtered mask
|
358 |
+
dfLanduses_gh = dfLanduses_gh.loc[valid_indexes]
|
359 |
+
|
360 |
else:
|
361 |
dfLanduses_gh = None
|
362 |
|