File size: 1,352 Bytes
4021dda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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"')