import streamlit as st import pandas as pd # Load the Excel file file_path = "Estimate Refer Database.xlsx" data = pd.read_excel(file_path, sheet_name=0) # Adjust column names for clarity data.columns = [ "Subtype", "Vancouver_Low", "Vancouver_High", "Calgary_Low", "Calgary_High", "Edmonton_Low", "Edmonton_High", "Winnipeg_Low", "Winnipeg_High", "Greater Toronto Area_Low", "Greater Toronto Area_High", "Ottawa/Gatineau_Low", "Ottawa/Gatineau_High", "Montreal_Low", "Montreal_High", "Halifax_Low", "Halifax_High", "St. John’s_Low", "St. John’s_High" ] # Remove the first row of labels (already captured in column names) data = data.iloc[1:].reset_index(drop=True) # Define cities and project types cities = [ "Vancouver", "Calgary", "Edmonton", "Winnipeg", "Greater Toronto Area", "Ottawa/Gatineau", "Montreal", "Halifax", "St. John’s" ] project_types = { "Office Buildings": [ "Under 5 Storeys (Class B)", "5- 30 Storeys (Class B)", "5- 30 Storeys (Class A)", "31 - 60 Storeys (Class A)", "Interior Fitout (Class B)", "Interior Fitout (Class A)" ], "Retail": ["Strip Plaza", "Supermarket", "Big Box Store", "Enclosed Mall"], "Hotels": ["Budget", "Suite Hotel", "4-star Full Service", "Premium for Luxury"], "Parking": [ "Surface Parking", "Freestanding Parking Garages (Above Grade)", "Underground Parking Garages", "Underground Parking Garages - Premium for Unusual Circumstances" ], "Industrial Facilities": ["Warehouse", "Distribution Facility", "Urban Storage Facility"] } def calculate_estimate(city, project_type, subtype, square_footage): """Calculate the cost estimate based on inputs.""" low_column = f"{city}_Low" high_column = f"{city}_High" # Filter data for the selected subtype filtered_data = data[data["Subtype"] == subtype] if filtered_data.empty or low_column not in data.columns or high_column not in data.columns: return None, None, None low_cost = float(filtered_data[low_column].values[0]) high_cost = float(filtered_data[high_column].values[0]) # Calculate estimates low_estimate = low_cost * square_footage high_estimate = high_cost * square_footage average_estimate = (low_estimate + high_estimate) / 2 return low_estimate, high_estimate, average_estimate # Custom CSS for styling st.markdown( """ """, unsafe_allow_html=True ) # State management for displaying inputs/results if "page" not in st.session_state: st.session_state.page = "input" # Default to input form # Render the input form if st.session_state.page == "input": # Custom CSS to center-align the text labels st.markdown(""" """, unsafe_allow_html=True) city = st.selectbox("Select a City", cities, index=4) project_type = st.selectbox("Select a Project Type", list(project_types.keys())) subtype = st.selectbox("Select a Subtype", project_types[project_type]) square_footage = st.slider("Select Square Footage", 0, 100000, 1000) if st.button("Get Estimate"): low_estimate, high_estimate, average_estimate = calculate_estimate(city, project_type, subtype, square_footage) if low_estimate is not None: st.session_state.result = { "city": city, "project_type": project_type, "subtype": subtype, "square_footage": square_footage, "low_estimate": low_estimate, "high_estimate": high_estimate, "average_estimate": average_estimate } st.session_state.page = "result" st.rerun() else: st.error("No data available for the selected inputs.") # Render the results page elif st.session_state.page == "result": st.markdown(""" """, unsafe_allow_html=True) result = st.session_state.result if st.button("Back"): st.session_state.page = "input" st.rerun() st.markdown(f"""
💰 Average Estimate:
${result['average_estimate']:,.2f}
Estimated Cost Range:
${result['low_estimate']:,.2f} - ${result['high_estimate']:,.2f}

Request Detailed Budget

To get a more detailed breakdown of your budget, contact us directly using the button above.

ℹ️
""", unsafe_allow_html=True)