Spaces:
Build error
Build error
| import pandas as pd | |
| import streamlit as st | |
| import seaborn as sns | |
| import matplotlib.pyplot as plt | |
| data = pd.read_csv('solar_power_data.csv') | |
| data['datetime'] = pd.to_datetime(data[['year', 'month', 'day', 'hour']]) | |
| data = data.set_index('datetime') | |
| data = data.drop(columns=['year', 'month', 'day', 'hour']) | |
| months = range(1, 13) | |
| years = sorted(data.index.year.unique()) | |
| st.title('Solar Power Generation Data') | |
| selected_year = st.sidebar.selectbox('Select Year', years) | |
| selected_month = st.sidebar.selectbox('Select Month', months) | |
| month_data = data[(data.index.year == selected_year) & (data.index.month == selected_month)] | |
| st.subheader(f'Solar Power Generation for {selected_year} - Month {selected_month:02d}') | |
| plt.figure(figsize=(14, 7)) | |
| fig, ax = plt.subplots(figsize=(14, 7)) | |
| fig.patch.set_facecolor('black') | |
| ax.set_facecolor('black') | |
| sns.lineplot(x=month_data.index, y=month_data['Watts_per_hr'], color='#00FF00', linewidth=2.5, ax=ax) | |
| ax.set_title(f'Solar Power Generation for {selected_year} - Month {selected_month:02d}', fontsize=18, weight='bold', color='white') | |
| ax.set_xlabel('Date', fontsize=14, color='white') | |
| ax.set_ylabel('Watts per Hour', fontsize=14, color='white') | |
| ax.tick_params(axis='both', colors='white') | |
| ax.grid(True, linestyle='--', alpha=0.7, color='gray') | |
| sns.despine() | |
| plt.xticks(rotation=45) | |
| plt.tight_layout() | |
| st.pyplot(fig) | |
| st.subheader('Data Table') | |
| st.write(month_data) | |