Spaces:
Sleeping
Sleeping
Commit
·
4021dda
1
Parent(s):
58d5a29
Upload 2 files
Browse files- app.py +44 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.express as px
|
4 |
+
|
5 |
+
|
6 |
+
st.set_page_config(page_title='Excel Plotter')
|
7 |
+
st.title('My Excel File Plotter Dashboard 👨🎓')
|
8 |
+
st.subheader('Prepare to be amazed as we transform your Excel file into stunning visualizations!')
|
9 |
+
|
10 |
+
|
11 |
+
uploaded_file = st.file_uploader('Choose a XLSX file', type='xlsx')
|
12 |
+
if uploaded_file:
|
13 |
+
st.markdown('---')
|
14 |
+
df = pd.read_excel(uploaded_file, engine='openpyxl')
|
15 |
+
st.dataframe(df)
|
16 |
+
|
17 |
+
lst=df.columns
|
18 |
+
groupby_column = st.selectbox(
|
19 |
+
'What would you like to analyse?',
|
20 |
+
lst,
|
21 |
+
)
|
22 |
+
####### It is better to extract above list from the dataframe, they might change
|
23 |
+
output_columns = st.multiselect(
|
24 |
+
'What would you like to analyse?',
|
25 |
+
lst,
|
26 |
+
)
|
27 |
+
|
28 |
+
#output_columns = ['Sales', 'Profit']
|
29 |
+
df_grouped = df.groupby(by=[groupby_column], as_index=False)[output_columns].sum()
|
30 |
+
|
31 |
+
# -- PLOT DATAFRAME
|
32 |
+
fig =px.bar(
|
33 |
+
df_grouped,
|
34 |
+
x=groupby_column,
|
35 |
+
y='Sales',
|
36 |
+
color='Profit',
|
37 |
+
color_continuous_scale=['blue', 'yellow', 'green',],
|
38 |
+
template='plotly_white',
|
39 |
+
title=f'<b>Sales & Profit by {groupby_column}</b>' )
|
40 |
+
st.plotly_chart(fig)
|
41 |
+
|
42 |
+
# -- DOWNLOAD SECTION
|
43 |
+
st.subheader('"Moreover, starting next week, we will be introducing a new feature that allows you to conveniently download these files, inshaAllah"')
|
44 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
plotly.express
|