Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,9 @@ import pandas as pd
|
|
| 5 |
data_file = "Estimate Refer Database.xlsx"
|
| 6 |
data = pd.read_excel(data_file, sheet_name=0)
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
# Define the cities and project types
|
| 9 |
cities = [
|
| 10 |
"Vancouver", "Calgary", "Edmonton", "Winnipeg", "GTA", "Ottawa/Gatineau", "Montreal", "Halifax", "St. John’s"
|
|
@@ -39,6 +42,13 @@ def calculate_estimate(city, project_type, subtype, square_footage):
|
|
| 39 |
if not city or not project_type or not subtype or not square_footage:
|
| 40 |
return "Please complete all selections to get an estimate."
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
# Filter the data for the selected city and subtype
|
| 43 |
filtered_data = data[(data["City"] == city) & (data["Subtype"] == subtype)]
|
| 44 |
|
|
@@ -75,6 +85,3 @@ estimate_button = st.button("Get Estimate")
|
|
| 75 |
if estimate_button:
|
| 76 |
result = calculate_estimate(city, project_type, subtype, square_footage)
|
| 77 |
st.write(result)
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
| 5 |
data_file = "Estimate Refer Database.xlsx"
|
| 6 |
data = pd.read_excel(data_file, sheet_name=0)
|
| 7 |
|
| 8 |
+
# Ensure column names are consistent
|
| 9 |
+
data.columns = data.columns.str.strip()
|
| 10 |
+
|
| 11 |
# Define the cities and project types
|
| 12 |
cities = [
|
| 13 |
"Vancouver", "Calgary", "Edmonton", "Winnipeg", "GTA", "Ottawa/Gatineau", "Montreal", "Halifax", "St. John’s"
|
|
|
|
| 42 |
if not city or not project_type or not subtype or not square_footage:
|
| 43 |
return "Please complete all selections to get an estimate."
|
| 44 |
|
| 45 |
+
# Debugging: Print the columns to verify names
|
| 46 |
+
st.write("Columns in the dataset:", data.columns)
|
| 47 |
+
|
| 48 |
+
# Check if required columns exist
|
| 49 |
+
if "City" not in data.columns or "Subtype" not in data.columns:
|
| 50 |
+
return "Required columns 'City' or 'Subtype' are missing in the dataset."
|
| 51 |
+
|
| 52 |
# Filter the data for the selected city and subtype
|
| 53 |
filtered_data = data[(data["City"] == city) & (data["Subtype"] == subtype)]
|
| 54 |
|
|
|
|
| 85 |
if estimate_button:
|
| 86 |
result = calculate_estimate(city, project_type, subtype, square_footage)
|
| 87 |
st.write(result)
|
|
|
|
|
|
|
|
|