Spaces:
Runtime error
Runtime error
import streamlit as st | |
import pandas as pd | |
c1, c2, c3 = st.columns([4,4,4]) | |
with c3: | |
st.image('gdmk logo.png', width=100, caption='GestioDinámica 2023') | |
with c1: | |
st.image('2017-GIZ-Logo.jpg', width=150, caption='Estudio de Encuesta Integridad') | |
# Load dataframe | |
file = st.file_uploader('Seleccione un archivo Excel: ') | |
if file is not None: | |
# Load the Excel file into a Pandas dataframe | |
df = pd.read_excel(file, engine='openpyxl') | |
# Show the dataframe in Streamlit | |
#st.write(df.head()) | |
#st.write(list(df.columns)) | |
# Sidebar option | |
option = st.sidebar.selectbox('Clasificar resultados por:', ('Pregunta', 'Categoria')) | |
# Group dataframe by chosen option | |
if option == 'Pregunta': | |
grouped_df = df.groupby('Pregunta') | |
elif option == 'Categoria': | |
grouped_df = df.groupby('Categoria') | |
# Generate text with bullets | |
text = '' | |
for name, group in grouped_df: | |
st.markdown('\n\n > ', option, ': ', name) | |
st.write('Cantidad de afirmaciones: ', len(group)) | |
texto_tot = '' | |
for index, row in group.iterrows(): | |
text = '* En el rubro sobre ' + row.Pregunta + ' la categoría ' + row.Categoria + ' responde ' + \ | |
row.Respuesta + ' un ' + str(row.dif2) + '% más que la categoría ' + row.Cat_Comparada + '\n' | |
texto_tot = texto_tot + '\n' + text | |
st.write(texto_tot) | |
# Download link for text file | |
st.markdown(f'<a href="data:text/plain;charset=utf-8,{texto_tot}" download="result.txt">Download Text File</a>', unsafe_allow_html=True) |