Spaces:
Runtime error
Runtime error
fix bug len(geosubset)=0
Browse files
app.py
CHANGED
|
@@ -92,12 +92,15 @@ with st.form("inputs"):
|
|
| 92 |
latlong_geo.to_crs(epsg=3857, inplace=True)
|
| 93 |
|
| 94 |
# Filter geosubset to only properties (sold since 2017)
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
if input_propertyType == 'Apartment':
|
| 103 |
propertyType_Apartment = 1
|
|
@@ -108,7 +111,7 @@ with st.form("inputs"):
|
|
| 108 |
elif input_propertyType == 'HDB':
|
| 109 |
propertyType_HDB = 1
|
| 110 |
|
| 111 |
-
latlong_geo['district'] = postal_final.loc[postal_final['2dpostal'] == input_postal[:2], 'district'].item()
|
| 112 |
latlong_geo['storey'] = input_storey
|
| 113 |
latlong_geo['age_asof_transaction'] = input_age_asof_transaction
|
| 114 |
latlong_geo['mindist_expway'] = latlong_geo.geometry.apply(lambda x: expressway.distance(x).min())
|
|
|
|
| 92 |
latlong_geo.to_crs(epsg=3857, inplace=True)
|
| 93 |
|
| 94 |
# Filter geosubset to only properties (sold since 2017)
|
| 95 |
+
try:
|
| 96 |
+
geosubset = geosubset[(geosubset['storey'] <= input_storey + 5) & (geosubset['storey'] >= input_storey - 5)] # filter storey +- 5
|
| 97 |
+
geosubset = geosubset[(geosubset['age_asof_t'] <= input_age_asof_transaction + 3) & (geosubset['age_asof_t'] >= input_age_asof_transaction - 3)] # filter age +- 3
|
| 98 |
+
geosubset = geosubset[(geosubset['floor_area'] <= input_floor_area_sqft + 100) & (geosubset['floor_area'] >= input_floor_area_sqft - 100)] # filter floor area to +- 50m
|
| 99 |
+
geosubset = geosubset[geosubset['propertyTy'] == input_propertyType] # filter property type
|
| 100 |
+
geosubset['distance_to_property'] = geosubset.geometry.apply(lambda x: latlong_geo.distance(x)) # filter property radius within 1km
|
| 101 |
+
geosubset = geosubset[geosubset['distance_to_property'] <= 1000] # filter distances within 1km
|
| 102 |
+
except:
|
| 103 |
+
pass
|
| 104 |
|
| 105 |
if input_propertyType == 'Apartment':
|
| 106 |
propertyType_Apartment = 1
|
|
|
|
| 111 |
elif input_propertyType == 'HDB':
|
| 112 |
propertyType_HDB = 1
|
| 113 |
|
| 114 |
+
latlong_geo['district'] = postal_final.loc[postal_final['2dpostal'] == input_postal[:2], 'district'].item() # all districts are covered in train set
|
| 115 |
latlong_geo['storey'] = input_storey
|
| 116 |
latlong_geo['age_asof_transaction'] = input_age_asof_transaction
|
| 117 |
latlong_geo['mindist_expway'] = latlong_geo.geometry.apply(lambda x: expressway.distance(x).min())
|