Spaces:
Build error
Build error
| import streamlit as st | |
| import pandas as pd | |
| import plotly.express as px | |
| st.set_page_config(page_title='Excel Plotter') | |
| st.title('My Excel File Plotter Dashboard π¨βπ') | |
| st.subheader('Prepare to be amazed as we transform your Excel file into stunning visualizations!') | |
| uploaded_file = st.file_uploader('Choose a XLSX file', type='xlsx') | |
| if uploaded_file: | |
| st.markdown('---') | |
| df = pd.read_excel(uploaded_file, engine='openpyxl') | |
| st.dataframe(df) | |
| lst=df.columns | |
| groupby_column = st.selectbox( | |
| 'What would you like to analyse?', | |
| lst, | |
| ) | |
| ####### It is better to extract above list from the dataframe, they might change | |
| output_columns = st.multiselect( | |
| 'What would you like to analyse?', | |
| lst, | |
| ) | |
| #output_columns = ['Sales', 'Profit'] | |
| df_grouped = df.groupby(by=[groupby_column], as_index=False)[output_columns].sum() | |
| # -- PLOT DATAFRAME | |
| fig =px.bar( | |
| df_grouped, | |
| x=groupby_column, | |
| y='Sales', | |
| color='Profit', | |
| color_continuous_scale=['blue', 'yellow', 'green',], | |
| template='plotly_white', | |
| title=f'<b>Sales & Profit by {groupby_column}</b>' ) | |
| st.plotly_chart(fig) | |
| # -- DOWNLOAD SECTION | |
| st.subheader('"Moreover, starting next week, we will be introducing a new feature that allows you to conveniently download these files, inshaAllah"') | |