ShreehariS754 commited on
Commit
0f106dc
·
verified ·
1 Parent(s): 4d971e8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+ import seaborn as sns
4
+ import matplotlib.pyplot as plt
5
+
6
+ data = pd.read_csv('solar_power_data.csv')
7
+ data['datetime'] = pd.to_datetime(data[['year', 'month', 'day', 'hour']])
8
+ data = data.set_index('datetime')
9
+ data = data.drop(columns=['year', 'month', 'day', 'hour'])
10
+
11
+ months = range(1, 13)
12
+ years = sorted(data.index.year.unique())
13
+
14
+ st.title('Solar Power Generation Data')
15
+
16
+ selected_year = st.sidebar.selectbox('Select Year', years)
17
+ selected_month = st.sidebar.selectbox('Select Month', months)
18
+
19
+ month_data = data[(data.index.year == selected_year) & (data.index.month == selected_month)]
20
+
21
+ st.subheader(f'Solar Power Generation for {selected_year} - Month {selected_month:02d}')
22
+
23
+ plt.figure(figsize=(14, 7))
24
+ fig, ax = plt.subplots(figsize=(14, 7))
25
+ fig.patch.set_facecolor('black')
26
+ ax.set_facecolor('black')
27
+
28
+ sns.lineplot(x=month_data.index, y=month_data['Watts_per_hr'], color='#00FF00', linewidth=2.5, ax=ax)
29
+
30
+ ax.set_title(f'Solar Power Generation for {selected_year} - Month {selected_month:02d}', fontsize=18, weight='bold', color='white')
31
+ ax.set_xlabel('Date', fontsize=14, color='white')
32
+ ax.set_ylabel('Watts per Hour', fontsize=14, color='white')
33
+ ax.tick_params(axis='both', colors='white')
34
+ ax.grid(True, linestyle='--', alpha=0.7, color='gray')
35
+
36
+ sns.despine()
37
+ plt.xticks(rotation=45)
38
+ plt.tight_layout()
39
+
40
+ st.pyplot(fig)
41
+
42
+ st.subheader('Data Table')
43
+ st.write(month_data)