Update app.py
Browse files1234456730 unmodified lines38394041424343444546474445464748495051525354555657495859606116 unmodified lines7879807281827483848586import streamlit as stimport pandas as pdimport numpy as np#import matplotlib.pyplot as pltimport matplotlib.pyplot as pltimport openai
# Load the solar data CSV file30 unmodified lines return system_cost, savings_per_month, payback_period
# Streamlit UIst.set_page_config(page_title="AI-based Solar Project Estimation Tool", layout="centered")st.title("AI-based Solar Project Estimation Tool")
# User input formst.sidebar.header("Enter Your Details")location = st.sidebar.text_input("Enter your city or state", "")roof_size = st.sidebar.number_input("Enter your roof size (in sq meters)", min_value=1)electricity_bill = st.sidebar.number_input("Enter your monthly electricity bill (₹)", min_value=0)# Center all input widgetsst.write("### Enter Your Details Below:")
with st.form("solar_form"): # Get the list of unique states from the dataset state_options = df['State'].dropna().unique() # Input widgets location = st.selectbox("Select your State", options=sorted(state_options)) roof_size = st.number_input("Enter your roof size (in sq meters)", min_value=1) electricity_bill = st.number_input("Enter your monthly electricity bill (₹)", min_value=0) submitted = st.form_submit_button("Get Estimate")
if location and roof_size > 0 and electricity_bill >= 0:if submitted and location and roof_size > 0 and electricity_bill >= 0: # Fetch state data from the dataset state_data = get_state_data(location) if state_data is not None:16 unmodified lines # Plot savings and payback period fig, ax = plt.subplots() ax.bar(['Total System Cost', 'Monthly Savings', 'Payback Period'], ax.bar(['Total System Cost', 'Monthly Savings', 'Payback Period (months)'], [system_cost, savings_per_month, payback_period*12], color=['blue', 'green', 'orange']) ax.set_ylabel("Amount (₹) / Time (years)") ax.set_ylabel("Amount (₹) / Time (Months)") ax.set_title("Solar System Estimation Breakdown") st.pyplot(fig) app.py+18-9