laverdes commited on
Commit
d3a3a91
1 Parent(s): 85902d5

chore: refactor code and comments

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -13,7 +13,8 @@ col1, col2 = st.columns(2)
13
  def convert_df(df):
14
  return df.to_csv(index=False).encode('utf-8')
15
 
16
-
 
17
  file_names, file_bytes = [], []
18
  with st.sidebar:
19
  files = st.file_uploader("Load files", accept_multiple_files = True)
@@ -45,6 +46,7 @@ with col1:
45
  else:
46
  st.caption("Upload your data using the sidebar to start :sunglasses:")
47
 
 
48
  with col2:
49
  if not df_base.empty:
50
  st.markdown("**Cleaning actions**")
@@ -80,6 +82,7 @@ with col2:
80
  elif detect_blinking and not number_of_blinks:
81
  st.caption("No blinking values were found in your data! ")
82
 
 
83
  with col2:
84
  if 'df' in list(st.session_state.keys()):
85
  df_right = st.session_state.df.copy(deep=True)
@@ -94,20 +97,11 @@ with col2:
94
  st.markdown("After adding calculated fields")
95
  st.dataframe(df_right)
96
  csv = convert_df(df_right)
97
- downl = st.download_button(
98
- "Download CSV 💾",
99
- csv,
100
- "file.csv",
101
- "text/csv",
102
- key='download-csv'
103
- )
104
  if downl:
105
  st.info("Your data has been downloaded, you can visualize and detect outliers in the 'Plotting' and 'Detect Outliers' pages on the sidebar.")
106
 
107
  if not df_base.empty:
108
- st.warning("Consider running outlier detection to clean your data!", icon="⚠️")
109
-
110
- # for key, value in st.session_state.items():
111
- # st.success(f"{key}: {value}")
112
-
113
- # reloading new samples would damage the st-session_state loading, vars are only written once
 
13
  def convert_df(df):
14
  return df.to_csv(index=False).encode('utf-8')
15
 
16
+
17
+ # Load a prepare data
18
  file_names, file_bytes = [], []
19
  with st.sidebar:
20
  files = st.file_uploader("Load files", accept_multiple_files = True)
 
46
  else:
47
  st.caption("Upload your data using the sidebar to start :sunglasses:")
48
 
49
+ # Cleaning starts
50
  with col2:
51
  if not df_base.empty:
52
  st.markdown("**Cleaning actions**")
 
82
  elif detect_blinking and not number_of_blinks:
83
  st.caption("No blinking values were found in your data! ")
84
 
85
+ # Add calculated fields
86
  with col2:
87
  if 'df' in list(st.session_state.keys()):
88
  df_right = st.session_state.df.copy(deep=True)
 
97
  st.markdown("After adding calculated fields")
98
  st.dataframe(df_right)
99
  csv = convert_df(df_right)
100
+
101
+ # Save transformations to disk
102
+ downl = st.download_button("Download CSV 💾", csv, "file.csv", "text/csv", key='download-csv')
 
 
 
 
103
  if downl:
104
  st.info("Your data has been downloaded, you can visualize and detect outliers in the 'Plotting' and 'Detect Outliers' pages on the sidebar.")
105
 
106
  if not df_base.empty:
107
+ st.warning("Consider running outlier detection to clean your data!", icon="⚠️")