laverdes commited on
Commit
aa639ce
β€’
1 Parent(s): 4ee3c5a

feat: plot it explanation and spinner

Browse files
Files changed (1) hide show
  1. pages/1_πŸ“ˆ_Plotting.py +22 -8
pages/1_πŸ“ˆ_Plotting.py CHANGED
@@ -1,5 +1,7 @@
1
  import streamlit as st
2
  import pandas as pd
 
 
3
 
4
  st.header("Plotting Time Series Data")
5
  st.markdown("Users can load their time-series data in **.csv** format and select a particular feature and plot-type.\
@@ -23,15 +25,18 @@ def plot_collection(plot_only_this, collection, number_of_desired_plots=0):
23
  if number_of_desired_plots:
24
  if plots_count == number_of_desired_plots:
25
  break
26
-
27
 
 
28
  with st.sidebar:
29
- plot = st.radio("Select the kind of visualization:",('Plot feature collection', 'Compare users', 'Plot distribution'))
30
  file = st.file_uploader("Load CSV file", accept_multiple_files = False)
31
  if file:
32
  df = pd.read_csv(file, index_col = False)
33
  # df.index = df['Unnamed: 0'].tolist()
34
- del df['Unnamed: 0']
 
 
 
35
  if 'df' not in st.session_state:
36
  st.session_state['df'] = df
37
  st.success("Your data has been successfully loaded! πŸ€—")
@@ -45,13 +50,22 @@ else:
45
  df_base = st.session_state.df if 'df' in list(st.session_state.keys()) else pd.DataFrame()
46
  n = len(df_base)
47
  col1, col2 = st.columns(2)
48
- with col1:
49
- if n:
 
50
  st.info(f"Your data has {n} samples.")
51
  slider_range = list(range(n))
52
  n_plot = st.slider("How many samples do you want to plot in the same graph", slider_range[0]+1, slider_range[-1]+1, 5)
53
  st.write(f"Action: {plot} using {n_plot} samples")
54
- st.button("Plot now! πŸ“Š")
55
-
56
- if not df_base.empty:
 
 
 
 
 
 
 
 
57
  st.warning("Consider running outlier detection to clean your data!", icon="⚠️")
 
1
  import streamlit as st
2
  import pandas as pd
3
+ import time
4
+
5
 
6
  st.header("Plotting Time Series Data")
7
  st.markdown("Users can load their time-series data in **.csv** format and select a particular feature and plot-type.\
 
25
  if number_of_desired_plots:
26
  if plots_count == number_of_desired_plots:
27
  break
 
28
 
29
+
30
  with st.sidebar:
31
+ plot = st.radio("Select the kind of visualization:",('Feature collection', 'Users comparison', 'Data distribution'))
32
  file = st.file_uploader("Load CSV file", accept_multiple_files = False)
33
  if file:
34
  df = pd.read_csv(file, index_col = False)
35
  # df.index = df['Unnamed: 0'].tolist()
36
+ try:
37
+ del df['Unnamed: 0']
38
+ except KeyError:
39
+ pass
40
  if 'df' not in st.session_state:
41
  st.session_state['df'] = df
42
  st.success("Your data has been successfully loaded! πŸ€—")
 
50
  df_base = st.session_state.df if 'df' in list(st.session_state.keys()) else pd.DataFrame()
51
  n = len(df_base)
52
  col1, col2 = st.columns(2)
53
+
54
+ if not df_base.empty:
55
+ with col1:
56
  st.info(f"Your data has {n} samples.")
57
  slider_range = list(range(n))
58
  n_plot = st.slider("How many samples do you want to plot in the same graph", slider_range[0]+1, slider_range[-1]+1, 5)
59
  st.write(f"Action: {plot} using {n_plot} samples")
60
+ plot_it = st.button("Plot now! πŸ“Š")
61
+ if plot_it:
62
+ with st.spinner(f"Drawing plot to visualize {plot.lower()}"):
63
+ while True:
64
+ time.sleep(4)
65
+ # create a DataFrame with each run in the columns (depending on n)
66
+ with st.expander("See explanation"):
67
+ st.write(\"\"\"
68
+ The chart above shows...
69
+ \"\"\")
70
+ else:
71
  st.warning("Consider running outlier detection to clean your data!", icon="⚠️")