data_ap / app.py
abdouramandalil's picture
Create app.py
7b74438 verified
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)