jcmachicao commited on
Commit
f2a4ed0
1 Parent(s): b906a5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -1,13 +1,26 @@
1
  import streamlit as st
2
  import pandas as pd
3
 
 
4
  file = st.file_uploader('Seleccione un archivo: ')
 
5
 
6
- if file is not None:
7
- dataxb = pd.read_pickle(file)
8
- st.write('Filas, Columnas de Data de Prueba: ', dataxb.shape)
9
- n_cols = len(dataxb.columns)
10
- n_cats = 2
11
-
12
- x = st.slider('Select a value')
13
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import pandas as pd
3
 
4
+ # Load dataframe
5
  file = st.file_uploader('Seleccione un archivo: ')
6
+ df = file
7
 
8
+ # Sidebar option
9
+ option = st.sidebar.selectbox('Classify results by:', ('Question', 'Category'))
10
+
11
+ # Group dataframe by chosen option
12
+ if option == 'Question':
13
+ grouped_df = df.groupby('Question')
14
+ elif option == 'Category':
15
+ grouped_df = df.groupby('Category')
16
+
17
+ # Generate text with bullets
18
+ text = ''
19
+ for name, group in grouped_df:
20
+ text += f'{name}:\n\n'
21
+ for index, row in group.iterrows():
22
+ text += f'- {row["Item"]}\n'
23
+ text += '\n'
24
+
25
+ # Download link for text file
26
+ st.markdown(f'<a href="data:text/plain;charset=utf-8,{text}" download="result.txt">Download Text File</a>', unsafe_allow_html=True)