import streamlit as st import pandas as pd from streamlit_folium import folium_static import numpy as np import folium import matplotlib.pyplot as plt import seaborn as sns from datetime import datetime, timedelta def main(): st.set_page_config(initial_sidebar_state="collapsed", layout="wide") data = { "favorite": [True, False, False, True, True, False, False, True], 'Address': ['Location_A', 'Location_B', 'Location_C', 'Location_D', 'Location_E', 'Location_F', 'Location_G', 'Location_H' ], 'latitude': np.random.uniform(40.7, 40.8, size=8), # Assuming latitude range between 40.7 and 40.8 'longitude': np.random.uniform(-74.0, -73.9, size=8), # Assuming longitude range between -74.0 and -73.9 'Match score': [90, 89, 88, 87, 86, 85, 84, 83], 'Market': ["M1", "M1", "M1", "M1", "M1", "M1", "M1", "M1"], 'Sub-market': ["S1", "S1", "S1", "S1", "S1", "S1", "S1", "S1"], '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"], 'LSF': [20000, 30000, 20000, 30000, 20000, 30000, 50000, 35000], 'RSF': [20000, 30000, 20000, 30000, 20000, 30000, 50000, 35000], 'Rent (NNN)': [11, 11, 11, 12, 12, 12, 12, 15], 'Year Built': [2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019], 'Office %': [20, 20, 20, 20, 20, 20, 20, 20], 'Clear Height':[19, 18, 19, 18, 17, 19, 19, 18], 'Doors (drive in / Dock)': [2, 2, 2, 2, 2, 2, 2, 2], 'Lease Term ': [60, 60, 60, 60, 60, 60, 60, 60], 'Rent (Gross)': [11, 11, 11, 12, 12, 12, 12, 15], 'TIs ': [1, 1, 1, 1, 1, 1, 1, 1] } # Create DataFrame df_data = pd.DataFrame(data) # df_data_checkbox = df_data.copy() # df_data_checkbox.insert(loc=0, column='Select rows', value=[False]*len(df_data)) 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)']] filtered_data = pd.concat([filtered_data2]) # Display the filtered data col_1_1, col_1_2 = st.columns([2, 1]) with col_1_1: st.write('Comps list:') display_df = st.table(filtered_data) with col_1_2: # Create a map object m = folium.Map(width=500, height=440, location=(df_data['latitude'].mean(), df_data['longitude'].mean()), zoom_start=10) # Add markers to the map all_markers = folium.FeatureGroup(name='All Markers') active_markers = folium.FeatureGroup(name='Active Markers', show=False) inactive_markers = folium.FeatureGroup(name='Inactive Markers', show=False) for index, row in df_data.iterrows(): status_color = 'green' if index%2==0 else 'red' html_content = f"""
{index}
""" # Create a DivIcon with custom HTML content icon = folium.DivIcon(html=html_content) marker = folium.Marker([row['latitude'], row['longitude']], popup=row['Address'], icon=icon).add_to(m) # Add layer control to toggle marker visibility folium.LayerControl().add_to(m) 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)] # Create a polygon object polygon = folium.Polygon(locations=polygon_coords, color='blue', fill=True, fill_color='blue', fill_opacity=0.3) # Add the tag to the polygon popup_text = "This is my polygon" popup = folium.Popup(popup_text, parse_html=True) polygon.add_child(popup) # Add the polygon to the map m.add_child(polygon) # Render the map folium_static(m) col_2_1, col_2_2, col_2_3 = st.columns([4, 4, 1]) with col_2_1: option = st.radio("Add comps:", (":rainbow[On]", ":rainbow[Off]"), horizontal=True, index=1) with col_2_2: if st.button("Predictions"): st.switch_page("pages/market_rent_estimation.py") with col_2_3: if st.button("Rexy"): st.switch_page("pages/rexy.py") if option == ":rainbow[On]": col_3_1, col_3_2, col_3_3 = st.columns([5,1,5]) with col_3_1: data5 = { "favorite": [False]*8, 'Address': ['B', 'B', 'B', 'B', 'B', 'B', 'B', 'B'], 'latitude': [40.7]*8, # Assuming latitude range between 40.7 and 40.8 'longitude': [-74.0]*8, # Assuming longitude range between -74.0 and -73.9 'Match score': [12, 12, 12, 12, 12, 12, 12, 12], 'Market': ["M2", "M2", "M2", "M2", "M2", "M2", "M2", "M2"], 'Sub-market': ["S2", "S2", "S2", "S2", "S2", "S2", "S2", "S2"], '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"], 'LSF': [20000, 30000, 20000, 30000, 20000, 30000, 50000, 35000], 'RSF': [20000, 30000, 20000, 30000, 20000, 30000, 50000, 35000], 'Rent (NNN)': [11, 11, 11, 12, 12, 12, 12, 15], 'Year Built': [2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019], 'Office %': [20, 20, 20, 20, 20, 20, 20, 20], 'Clear Height':[19, 18, 19, 18, 17, 19, 19, 18], 'Doors (drive in / Dock)': [2, 2, 2, 2, 2, 2, 2, 2], 'Lease Term ': [60, 60, 60, 60, 60, 60, 60, 60], 'Rent (Gross)': [11, 11, 11, 12, 12, 12, 12, 15], 'TIs ': [1, 1, 1, 1, 1, 1, 1, 1] } # Create DataFrame df5 = pd.DataFrame(data5) # df5.insert(loc=0, column='Select rows', value=[False]*len(df5)) st.write('Additional comps') test = st.data_editor( df5, column_config={ "favorite": st.column_config.CheckboxColumn( "Your favorite?", help="Select your **favorite** widgets", default=False, ) }, disabled=['Address','latitude','longitude','Match score','Market','Sub-market','Lease Date','LSF', 'RSF','Rent (NNN)','Year Built','Office %','Clear Height','Doors (drive in / Dock)','Lease Term ','Rent (Gross)','TIs '], hide_index=True, ) with col_3_2: if st.button("Add comps", help="Click to add more comps"): filtered_data1 = pd.concat([filtered_data, test.drop(columns=['favorite'])]) # filtered_data.update(test.drop(columns=['favorite'])) display_df.table(filtered_data1) with col_3_3: st.write('Filter definition') range_1 = st.slider('Lease date', min_value=0, max_value=36, value=(12)) range_2 = st.slider('Location in mi', min_value=0, max_value=50, value=(12)) range_3 = st.slider('LSF', min_value=0, max_value=500000, step = 1000, value=(20000, 200000)) range_4 = st.slider('Clear height', min_value=0, max_value=50, value=(15, 30)) range_5 = st.slider('Year built', min_value=1960, max_value=2024, value=(1999, 2010)) range_5 = st.slider('Far %', min_value=0, max_value=100, value=50) range_6 = st.slider('Office %', min_value=0, max_value=100, value=30) range_7 = st.slider('Docl doors & Drive-in', min_value=0, max_value=20, value=3) st.button("Apply filter", key="submit_button", help="Click to submit") if __name__ == "__main__": main()