File size: 1,289 Bytes
7b74438
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
import streamlit as st 
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import time

df = pd.read_csv('bank.csv')
st.set_page_config(page_title='Real time dashboard',
page_icon = '✅',layout="wide")

#DASHBOARD TITLE
st.title('Real time dashbord analysis')
#filtre sur le type de job
job_filter = st.selectbox('select a job',pd.unique(df['job']))
df = df[df['job']== job_filter]

#Creation d indicateurs
avg_age = np.mean(df['age'])
count_married = int(df[(df['marital'] == 'married')]['marital'].count())
balance = np.mean(df['balance'])

kpi1,kpi2,kpi3= st.columns(3)
kpi1.metric(label='Age ⏳',value=round(avg_age),delta=round(avg_age))
kpi2.metric(label='Married Count 💍', value=count_married,
             delta= round(count_married))
kpi3.metric(label='Balance $',value=f'$ {round(balance,2)}',
    delta = round(balance/count_married)*100)
#Graphiques
col1,col2 = st.columns(2)
with col1:
    st.markdown('### First chart')
    fig1 = plt.figure()
    sns.barplot(data=df,x='marital',y='age',palette='muted')
    st.pyplot(fig1)
with col2:
    st.markdown('### Second chart')
    fig2 = plt.figure()
    sns.histplot(data=df,x='age',palette='muted')
    st.pyplot(fig2)
st.markdown('### Detailed data view')
st.dataframe(df)