feat: update summary charts
Browse filesBoxplot show data on hover
Add dist plot (histogram and violin plot)
- src/app.py +7 -3
- src/data/utils.py +3 -1
- src/visualization/visualize.py +9 -3
src/app.py
CHANGED
@@ -14,12 +14,16 @@ def main():
|
|
14 |
sample_data_selected = st.selectbox(
|
15 |
'Select sample data:', data_set_options)
|
16 |
|
17 |
-
data = import_sample_data(
|
|
|
18 |
|
19 |
show_inputted_dataframe(data)
|
20 |
|
21 |
-
with st.expander("Box
|
22 |
-
time_series_box_plot(
|
|
|
|
|
|
|
23 |
|
24 |
st.header("Time series decomposition")
|
25 |
|
|
|
14 |
sample_data_selected = st.selectbox(
|
15 |
'Select sample data:', data_set_options)
|
16 |
|
17 |
+
data, graph_data = import_sample_data(
|
18 |
+
sample_data_selected, data_set_options)
|
19 |
|
20 |
show_inputted_dataframe(data)
|
21 |
|
22 |
+
with st.expander("Box Plot:"):
|
23 |
+
time_series_box_plot(graph_data)
|
24 |
+
|
25 |
+
with st.expander("Dist Plot (histogram and violin plot):"):
|
26 |
+
time_series_violin_and_box_plot(data)
|
27 |
|
28 |
st.header("Time series decomposition")
|
29 |
|
src/data/utils.py
CHANGED
@@ -14,4 +14,6 @@ def import_sample_data(sample_data_selected, data_set_options):
|
|
14 |
data = pd.read_csv('data/processed/milk_production.csv',
|
15 |
parse_dates=['date'], index_col='date')
|
16 |
|
17 |
-
|
|
|
|
|
|
14 |
data = pd.read_csv('data/processed/milk_production.csv',
|
15 |
parse_dates=['date'], index_col='date')
|
16 |
|
17 |
+
graph_data = data.reset_index()
|
18 |
+
graph_data.columns.values[0] = 'Date'
|
19 |
+
return data, graph_data
|
src/visualization/visualize.py
CHANGED
@@ -27,7 +27,7 @@ def streamlit_2columns_metrics_df_shape(df: pd.DataFrame):
|
|
27 |
|
28 |
|
29 |
def show_inputted_dataframe(data):
|
30 |
-
with st.expander("Input Dataframe
|
31 |
st.dataframe(data)
|
32 |
streamlit_2columns_metrics_df_shape(data)
|
33 |
|
@@ -37,7 +37,7 @@ def standard_decomposition_plot(decomposition):
|
|
37 |
fig = decomposition.plot()
|
38 |
|
39 |
(xsize_standard_decomp, ysize_standard_decomp) = streamlit_chart_setting_height_width(
|
40 |
-
"Chart
|
41 |
|
42 |
fig.set_size_inches(xsize_standard_decomp, ysize_standard_decomp)
|
43 |
|
@@ -57,7 +57,13 @@ def time_series_scatter_plot(data):
|
|
57 |
|
58 |
|
59 |
def time_series_box_plot(data):
|
60 |
-
fig = px.box(data, points="all")
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
st.plotly_chart(fig, use_container_width=True)
|
62 |
|
63 |
|
|
|
27 |
|
28 |
|
29 |
def show_inputted_dataframe(data):
|
30 |
+
with st.expander("Input Dataframe:"):
|
31 |
st.dataframe(data)
|
32 |
streamlit_2columns_metrics_df_shape(data)
|
33 |
|
|
|
37 |
fig = decomposition.plot()
|
38 |
|
39 |
(xsize_standard_decomp, ysize_standard_decomp) = streamlit_chart_setting_height_width(
|
40 |
+
"Chart Size:", 5, 5, "xsize_standard_decomp", "ysize_standard_decomp")
|
41 |
|
42 |
fig.set_size_inches(xsize_standard_decomp, ysize_standard_decomp)
|
43 |
|
|
|
57 |
|
58 |
|
59 |
def time_series_box_plot(data):
|
60 |
+
fig = px.box(data, hover_data=['Date'], points="all")
|
61 |
+
st.plotly_chart(fig, use_container_width=True)
|
62 |
+
|
63 |
+
|
64 |
+
def time_series_violin_and_box_plot(graph_data):
|
65 |
+
fig = px.histogram(graph_data,
|
66 |
+
marginal="violin")
|
67 |
st.plotly_chart(fig, use_container_width=True)
|
68 |
|
69 |
|