Spaces:
Sleeping
Sleeping
refactored main file
Browse files
app.py
CHANGED
|
@@ -3,33 +3,26 @@ import pandas as pd, panel as pn
|
|
| 3 |
import hvplot.pandas # noqa
|
| 4 |
|
| 5 |
# Data loading and cleaning
|
| 6 |
-
df = pd.read_csv('omoku_data.csv',
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
2: 'Wednesday',
|
| 12 |
-
3: 'Thursday',
|
| 13 |
-
4: 'Friday',
|
| 14 |
-
5: 'Saturday',
|
| 15 |
-
6: 'Sunday'
|
| 16 |
-
}
|
| 17 |
-
days = list(day_order.values())
|
| 18 |
|
| 19 |
-
|
| 20 |
-
max_power = df['Power_time'].max()
|
| 21 |
-
min_power = df['Power_time'].min()
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# Plots
|
| 28 |
-
box_plot =
|
| 29 |
-
line_plot =
|
| 30 |
-
density_plot =
|
| 31 |
-
|
| 32 |
-
weekly_group = df.groupby('Day', sort=False).mean().reindex(days)
|
| 33 |
weekly_plot = weekly_group.hvplot.bar(stacked=True, rot=45, ylabel='Number of hours', title='Average power supply by week day')
|
| 34 |
|
| 35 |
# Dashboard
|
|
|
|
| 3 |
import hvplot.pandas # noqa
|
| 4 |
|
| 5 |
# Data loading and cleaning
|
| 6 |
+
df = pd.read_csv('omoku_data.csv', index_col='Date', parse_dates=True)
|
| 7 |
|
| 8 |
+
def clean_df(df):
|
| 9 |
+
df = df[df['Remark'].isna()]
|
| 10 |
+
return df.assign(Day=df.index.day_name())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
cleaned_df = clean_df(df)
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
daily_average = cleaned_df['Power_time'].mean()
|
| 15 |
+
max_power = cleaned_df['Power_time'].max()
|
| 16 |
+
min_power = cleaned_df['Power_time'].min()
|
| 17 |
+
|
| 18 |
+
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
|
| 19 |
+
weekly_group = cleaned_df.groupby('Day', sort=False)[['Power_time', 'Outages']].mean().reindex(days)
|
| 20 |
|
| 21 |
# Plots
|
| 22 |
+
box_plot = cleaned_df.hvplot.box(xlabel="Variables", ylabel="Number of hours", grid=True, title="Box Plot of Power Time and Outages")
|
| 23 |
+
line_plot = cleaned_df.hvplot.line(y='Power_time', ylabel='Number of hours', title='Daily power supply')
|
| 24 |
+
density_plot = cleaned_df.hvplot.kde('Power_time', xlabel='Number of hours', xlim=(0,24), yaxis=None, hover=False,
|
| 25 |
+
title='Density distribution of power supply').opts(padding=(0,0))
|
|
|
|
| 26 |
weekly_plot = weekly_group.hvplot.bar(stacked=True, rot=45, ylabel='Number of hours', title='Average power supply by week day')
|
| 27 |
|
| 28 |
# Dashboard
|