Spaces:
Sleeping
Sleeping
Update pages/comps_data.py
Browse files- pages/comps_data.py +123 -120
pages/comps_data.py
CHANGED
|
@@ -12,135 +12,138 @@ import matplotlib.pyplot as plt
|
|
| 12 |
import seaborn as sns
|
| 13 |
from datetime import datetime, timedelta
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
def add_checkbox_column(df):
|
| 19 |
-
checkbox_col = st.multiselect("Select rows", df.index.tolist(), [])
|
| 20 |
-
df.insert(0, "Checkbox", False)
|
| 21 |
-
for index in checkbox_col:
|
| 22 |
-
df.at[index, "Checkbox"] = True
|
| 23 |
-
return df
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
data = {
|
| 27 |
-
'Address': ['Location_A', 'Location_B', 'Location_C', 'Location_D', 'Location_E',
|
| 28 |
-
'Location_F', 'Location_G', 'Location_H'
|
| 29 |
-
],
|
| 30 |
-
'latitude': np.random.uniform(40.7, 40.8, size=8), # Assuming latitude range between 40.7 and 40.8
|
| 31 |
-
'longitude': np.random.uniform(-74.0, -73.9, size=8), # Assuming longitude range between -74.0 and -73.9
|
| 32 |
-
'Match score': [90, 89, 88, 87, 86, 85, 84, 83],
|
| 33 |
-
'Market': ["M1", "M1", "M1", "M1", "M1", "M1", "M1", "M1"],
|
| 34 |
-
'Sub-market': ["S1", "S1", "S1", "S1", "S1", "S1", "S1", "S1"],
|
| 35 |
-
'Lease Date': ["2024/1/1", "2024/1/1", "2024/1/1", "2024/1/1", "2024/1/1", "2024/1/1", "2024/1/1", "2024/1/1"],
|
| 36 |
-
'LSF': [20000, 30000, 20000, 30000, 20000, 30000, 50000, 35000],
|
| 37 |
-
'RSF': [20000, 30000, 20000, 30000, 20000, 30000, 50000, 35000],
|
| 38 |
-
'Rent (NNN)': [11, 11, 11, 12, 12, 12, 12, 15],
|
| 39 |
-
'Year Built': [2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019],
|
| 40 |
-
'Office %': [20, 20, 20, 20, 20, 20, 20, 20],
|
| 41 |
-
'Clear Height':[19, 18, 19, 18, 17, 19, 19, 18],
|
| 42 |
-
'Doors (drive in / Dock)': [2, 2, 2, 2, 2, 2, 2, 2],
|
| 43 |
-
'Lease Term ': [60, 60, 60, 60, 60, 60, 60, 60],
|
| 44 |
-
'Rent (Gross)': [11, 11, 11, 12, 12, 12, 12, 15],
|
| 45 |
-
'TIs ': [1, 1, 1, 1, 1, 1, 1, 1]
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
# Create DataFrame
|
| 49 |
-
df_data = pd.DataFrame(data)
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
df_data_checkbox = df_data.copy()
|
| 53 |
-
df_data_checkbox.insert(loc=0, column='Select rows', value=[False]*len(df_data))
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
filtered_data2 = df_data[['Address', 'Market', 'Sub-market', 'Lease Date', 'LSF', 'RSF', 'Rent (NNN)', 'Year Built', 'Office %', 'Clear Height', 'Doors (drive in / Dock)', 'Lease Term ', 'Rent (Gross)']]
|
| 57 |
-
filtered_data = pd.concat([filtered_data2, filtered_data2, filtered_data2, filtered_data2])
|
| 58 |
-
|
| 59 |
-
# Display the filtered data
|
| 60 |
-
col_1_1, col_1_2 = st.columns([2, 1])
|
| 61 |
-
with col_1_1:
|
| 62 |
-
st.write('Comps list:')
|
| 63 |
-
st.write(filtered_data)
|
| 64 |
-
with col_1_2:
|
| 65 |
-
# Create a map object
|
| 66 |
-
m = folium.Map(width=500, height=440, location=(df_data['latitude'].mean(), df_data['longitude'].mean()), zoom_start=10)
|
| 67 |
-
|
| 68 |
-
# Add markers to the map
|
| 69 |
-
all_markers = folium.FeatureGroup(name='All Markers')
|
| 70 |
-
active_markers = folium.FeatureGroup(name='Active Markers', show=False)
|
| 71 |
-
inactive_markers = folium.FeatureGroup(name='Inactive Markers', show=False)
|
| 72 |
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
border: 2px solid black;
|
| 81 |
-
border-radius: 50%;
|
| 82 |
-
width: 20px;
|
| 83 |
-
height: 20px;
|
| 84 |
-
text-align: center;
|
| 85 |
-
line-height: 20px;
|
| 86 |
-
font-size: 8pt;
|
| 87 |
-
color: {status_color};
|
| 88 |
-
">{index}</div>
|
| 89 |
-
"""
|
| 90 |
|
| 91 |
-
# Create a DivIcon with custom HTML content
|
| 92 |
-
icon = folium.DivIcon(html=html_content)
|
| 93 |
-
marker = folium.Marker([row['latitude'], row['longitude']], popup=row['Address'], icon=icon).add_to(m)
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
-
#
|
| 97 |
-
|
| 98 |
|
| 99 |
-
polygon_coords = [ [np.random.uniform(40.7, 40.8, size=6)[i], np.random.uniform(-74.0, -73.9, size=6)[i]] for i in range(6)]
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
|
| 104 |
-
# Add the tag to the polygon
|
| 105 |
-
popup_text = "This is my polygon"
|
| 106 |
-
popup = folium.Popup(popup_text, parse_html=True)
|
| 107 |
-
polygon.add_child(popup)
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
|
|
|
|
|
|
|
|
| 12 |
import seaborn as sns
|
| 13 |
from datetime import datetime, timedelta
|
| 14 |
|
| 15 |
+
def main():
|
| 16 |
+
st.set_page_config(initial_sidebar_state="collapsed", layout="wide")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
+
def add_checkbox_column(df):
|
| 20 |
+
checkbox_col = st.multiselect("Select rows", df.index.tolist(), [])
|
| 21 |
+
df.insert(0, "Checkbox", False)
|
| 22 |
+
for index in checkbox_col:
|
| 23 |
+
df.at[index, "Checkbox"] = True
|
| 24 |
+
return df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
data = {
|
| 28 |
+
'Address': ['Location_A', 'Location_B', 'Location_C', 'Location_D', 'Location_E',
|
| 29 |
+
'Location_F', 'Location_G', 'Location_H'
|
| 30 |
+
],
|
| 31 |
+
'latitude': np.random.uniform(40.7, 40.8, size=8), # Assuming latitude range between 40.7 and 40.8
|
| 32 |
+
'longitude': np.random.uniform(-74.0, -73.9, size=8), # Assuming longitude range between -74.0 and -73.9
|
| 33 |
+
'Match score': [90, 89, 88, 87, 86, 85, 84, 83],
|
| 34 |
+
'Market': ["M1", "M1", "M1", "M1", "M1", "M1", "M1", "M1"],
|
| 35 |
+
'Sub-market': ["S1", "S1", "S1", "S1", "S1", "S1", "S1", "S1"],
|
| 36 |
+
'Lease Date': ["2024/1/1", "2024/1/1", "2024/1/1", "2024/1/1", "2024/1/1", "2024/1/1", "2024/1/1", "2024/1/1"],
|
| 37 |
+
'LSF': [20000, 30000, 20000, 30000, 20000, 30000, 50000, 35000],
|
| 38 |
+
'RSF': [20000, 30000, 20000, 30000, 20000, 30000, 50000, 35000],
|
| 39 |
+
'Rent (NNN)': [11, 11, 11, 12, 12, 12, 12, 15],
|
| 40 |
+
'Year Built': [2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019],
|
| 41 |
+
'Office %': [20, 20, 20, 20, 20, 20, 20, 20],
|
| 42 |
+
'Clear Height':[19, 18, 19, 18, 17, 19, 19, 18],
|
| 43 |
+
'Doors (drive in / Dock)': [2, 2, 2, 2, 2, 2, 2, 2],
|
| 44 |
+
'Lease Term ': [60, 60, 60, 60, 60, 60, 60, 60],
|
| 45 |
+
'Rent (Gross)': [11, 11, 11, 12, 12, 12, 12, 15],
|
| 46 |
+
'TIs ': [1, 1, 1, 1, 1, 1, 1, 1]
|
| 47 |
+
}
|
| 48 |
|
| 49 |
+
# Create DataFrame
|
| 50 |
+
df_data = pd.DataFrame(data)
|
| 51 |
|
|
|
|
| 52 |
|
| 53 |
+
df_data_checkbox = df_data.copy()
|
| 54 |
+
df_data_checkbox.insert(loc=0, column='Select rows', value=[False]*len(df_data))
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
+
filtered_data2 = df_data[['Address', 'Market', 'Sub-market', 'Lease Date', 'LSF', 'RSF', 'Rent (NNN)', 'Year Built', 'Office %', 'Clear Height', 'Doors (drive in / Dock)', 'Lease Term ', 'Rent (Gross)']]
|
| 58 |
+
filtered_data = pd.concat([filtered_data2, filtered_data2, filtered_data2, filtered_data2])
|
| 59 |
|
| 60 |
+
# Display the filtered data
|
| 61 |
+
col_1_1, col_1_2 = st.columns([2, 1])
|
| 62 |
+
with col_1_1:
|
| 63 |
+
st.write('Comps list:')
|
| 64 |
+
st.write(filtered_data)
|
| 65 |
+
with col_1_2:
|
| 66 |
+
# Create a map object
|
| 67 |
+
m = folium.Map(width=500, height=440, location=(df_data['latitude'].mean(), df_data['longitude'].mean()), zoom_start=10)
|
| 68 |
|
| 69 |
+
# Add markers to the map
|
| 70 |
+
all_markers = folium.FeatureGroup(name='All Markers')
|
| 71 |
+
active_markers = folium.FeatureGroup(name='Active Markers', show=False)
|
| 72 |
+
inactive_markers = folium.FeatureGroup(name='Inactive Markers', show=False)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
for index, row in df_data.iterrows():
|
| 76 |
+
status_color = 'green' if index%2==0 else 'red'
|
| 77 |
+
html_content = f"""
|
| 78 |
+
<div style="
|
| 79 |
+
display: inline-block;
|
| 80 |
+
background-color: white;
|
| 81 |
+
border: 2px solid black;
|
| 82 |
+
border-radius: 50%;
|
| 83 |
+
width: 20px;
|
| 84 |
+
height: 20px;
|
| 85 |
+
text-align: center;
|
| 86 |
+
line-height: 20px;
|
| 87 |
+
font-size: 8pt;
|
| 88 |
+
color: {status_color};
|
| 89 |
+
">{index}</div>
|
| 90 |
+
"""
|
| 91 |
+
|
| 92 |
+
# Create a DivIcon with custom HTML content
|
| 93 |
+
icon = folium.DivIcon(html=html_content)
|
| 94 |
+
marker = folium.Marker([row['latitude'], row['longitude']], popup=row['Address'], icon=icon).add_to(m)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
# Add layer control to toggle marker visibility
|
| 98 |
+
folium.LayerControl().add_to(m)
|
| 99 |
+
|
| 100 |
+
polygon_coords = [ [np.random.uniform(40.7, 40.8, size=6)[i], np.random.uniform(-74.0, -73.9, size=6)[i]] for i in range(6)]
|
| 101 |
+
|
| 102 |
+
# Create a polygon object
|
| 103 |
+
polygon = folium.Polygon(locations=polygon_coords, color='blue', fill=True, fill_color='blue', fill_opacity=0.3)
|
| 104 |
+
|
| 105 |
+
# Add the tag to the polygon
|
| 106 |
+
popup_text = "This is my polygon"
|
| 107 |
+
popup = folium.Popup(popup_text, parse_html=True)
|
| 108 |
+
polygon.add_child(popup)
|
| 109 |
+
|
| 110 |
+
# Add the polygon to the map
|
| 111 |
+
m.add_child(polygon)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
# Render the map
|
| 115 |
+
folium_static(m)
|
| 116 |
+
col_2_1, col_2_2, col_2_3 = st.columns([1, 1, 1])
|
| 117 |
+
with col_2_1:
|
| 118 |
+
option = st.radio("Add comps:", (":rainbow[On]", ":rainbow[Off]"), horizontal=True, index=1)
|
| 119 |
+
|
| 120 |
+
with col_2_2:
|
| 121 |
+
if st.button("Comps"):
|
| 122 |
+
st.switch_page("pages/comps_data.py")
|
| 123 |
+
|
| 124 |
+
# Add the second button on the right side
|
| 125 |
+
with col_2_3:
|
| 126 |
+
st.button("Right Button")
|
| 127 |
+
# if option == ":rainbow[On]":
|
| 128 |
+
|
| 129 |
+
col_3_1, col_3_2 = st.columns(2)
|
| 130 |
+
with col_3_1:
|
| 131 |
+
# c1 = st.container(height=120)
|
| 132 |
+
# df_data_checkbox = add_checkbox_column(df_data)
|
| 133 |
+
|
| 134 |
+
st.data_editor(
|
| 135 |
+
df_data_checkbox,
|
| 136 |
+
column_config={
|
| 137 |
+
"Select rows": st.column_config.CheckboxColumn(required=True),
|
| 138 |
+
},
|
| 139 |
+
disabled=["widgets"],
|
| 140 |
+
hide_index=True,
|
| 141 |
+
)
|
| 142 |
+
|
| 143 |
+
with col_3_2:
|
| 144 |
+
c2 = st.container(height=120)
|
| 145 |
+
c2.write('Comps list:')
|
| 146 |
+
c2.write(filtered_data)
|
| 147 |
|
| 148 |
+
if __name__ == "__main__":
|
| 149 |
+
main()
|