Spaces:
Runtime error
Runtime error
chore: columns refactor
Browse files
app.py
CHANGED
@@ -42,13 +42,17 @@ with col1:
|
|
42 |
df_base["len_pupil_dilation"] = df_base.pupil_dilation.map(lambda l: len(l))
|
43 |
df_base["len_baseline"] = df_base.baseline.map(lambda l: len(l))
|
44 |
st.info(f"number of files: {len(file_names)}")
|
45 |
-
|
46 |
-
|
47 |
else:
|
48 |
st.caption("Upload your data using the sidebar to start :sunglasses:")
|
49 |
|
|
|
|
|
|
|
|
|
50 |
# Cleaning starts
|
51 |
-
with
|
52 |
if not df_base.empty:
|
53 |
st.markdown("**Cleaning actions**")
|
54 |
detect_blinking = st.button("I want to clean my data 🤗")
|
@@ -84,25 +88,24 @@ with col2:
|
|
84 |
st.caption("No blinking values were found in your data! ")
|
85 |
|
86 |
# Add calculated fields
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
csv = convert_df(df_right)
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
|
107 |
if not df_base.empty:
|
108 |
with col1:
|
|
|
42 |
df_base["len_pupil_dilation"] = df_base.pupil_dilation.map(lambda l: len(l))
|
43 |
df_base["len_baseline"] = df_base.baseline.map(lambda l: len(l))
|
44 |
st.info(f"number of files: {len(file_names)}")
|
45 |
+
if 'df_base' not in st.session_state:
|
46 |
+
st.session_state['df_base'] = df_base
|
47 |
else:
|
48 |
st.caption("Upload your data using the sidebar to start :sunglasses:")
|
49 |
|
50 |
+
if 'df_base' in st.session_state:
|
51 |
+
st.markdown("Your original data with some extra information about the length of the time-series fields")
|
52 |
+
st.dataframe(st.session_state.df_base)
|
53 |
+
|
54 |
# Cleaning starts
|
55 |
+
with col1:
|
56 |
if not df_base.empty:
|
57 |
st.markdown("**Cleaning actions**")
|
58 |
detect_blinking = st.button("I want to clean my data 🤗")
|
|
|
88 |
st.caption("No blinking values were found in your data! ")
|
89 |
|
90 |
# Add calculated fields
|
91 |
+
if 'df' in list(st.session_state.keys()):
|
92 |
+
df_right = st.session_state.df.copy(deep=True)
|
93 |
+
if "baseline" in list(df_right.keys()):
|
94 |
+
st.markdown(f"A **baseline** feature has been found on your data, do you want to merge it with any of the other features in a new calculated field?")
|
95 |
+
option = st.multiselect('Select a feature to create relative calculated feature ➕', [k for k in list(df_right.keys()) if k != 'baseline'], [[k for k in list(df_right.keys()) if k != 'baseline'][-4]])
|
96 |
+
relative_key = f"relative_{option[0]}"
|
97 |
+
add_relative = st.button(f"Add {relative_key}")
|
98 |
+
if add_relative:
|
99 |
+
baseline_mean = [sum(s)/len(s) for s in df_right['baseline']]
|
100 |
+
df_right[relative_key] = [[field_value - baseline_mean[i] for field_value in df_right[option[0]][i]] for i in range(len(df_right))]
|
101 |
+
st.markdown("After adding calculated fields")
|
102 |
+
st.dataframe(df_right)
|
103 |
+
csv = convert_df(df_right)
|
|
|
104 |
|
105 |
+
# Save transformations to disk
|
106 |
+
downl = st.download_button("Download CSV 💾", csv, "file.csv", "text/csv", key='download-csv')
|
107 |
+
if downl:
|
108 |
+
st.info("Your data has been downloaded, you can visualize and detect outliers in the 'Plotting' and 'Detect Outliers' pages on the sidebar.")
|
109 |
|
110 |
if not df_base.empty:
|
111 |
with col1:
|