Skip to content

Commit aa682a7

Browse files
Merge pull request #229 from Quantum-Software-Development/FabianaCampanari-patch-1
Add Streamlit dashboard with Excel filters
2 parents 4f44c46 + 204c6e5 commit aa682a7

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
import streamlit as st
3+
import pandas as pd
4+
import numpy as np
5+
6+
7+
df1=pd.read_excel("BASE01.CREDITO.xlsx")
8+
df2=pd.read_excel("BASE02.CREDITO.xlsx")
9+
df=df1
10+
11+
12+
st.title("Layout: Sidebar, Colunas e Abas")
13+
14+
# SIDEBAR
15+
st.sidebar.header("Filtros")
16+
with st.sidebar:
17+
#idade_min, idade_max = (\
18+
#int(df["idade"].min()), int(df["idade"].max())) \
19+
#if "idade" in df else (0, 0)
20+
idade_min=df["idade"].min()
21+
idade_max=df["idade"].max()
22+
idade_sel = st.slider(\
23+
"Faixa de idade", idade_min, idade_max,\
24+
(idade_min, idade_max), step=1)
25+
regiao=st.selectbox(\
26+
"Região",options=df["regiao"].unique())
27+
base=st.radio("BASE",options=[1,2])
28+
29+
30+
if base==1:
31+
df=df1
32+
else:
33+
df=df2
34+
35+
dfMediaSexo=df[["sexo","valorcredito"]].groupby(by=["sexo"]).sum().reset_index()
36+
37+
# ABAS
38+
st.write("Filtrado pela região "+regiao)
39+
aba1, aba2,aba3 = st.tabs(["Tabela", \
40+
"Estatísticas","Gráfico"])
41+
with aba1:
42+
fdf = df[(df["idade"] >= idade_sel[0]) \
43+
& (df["idade"] <= idade_sel[1])]
44+
fdf=fdf[fdf["regiao"]==regiao]
45+
st.dataframe(fdf)
46+
with aba2:
47+
fdf = df[(df["idade"] >= idade_sel[0]) \
48+
& (df["idade"] <= idade_sel[1])]
49+
fdf=fdf[fdf["regiao"]==regiao]
50+
st.write(fdf.describe())
51+
with aba3:
52+
fdf = df[(df["idade"] >= idade_sel[0]) \
53+
& (df["idade"] <= idade_sel[1])]
54+
fdf=fdf[fdf["regiao"]==regiao]
55+
dfMediaSexo=fdf[["sexo","valorcredito"]].\
56+
groupby(by=["sexo"]).sum().reset_index()
57+
st.bar_chart(data=dfMediaSexo,\
58+
x="sexo",y="valorcredito")

0 commit comments

Comments
 (0)