Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
import pandas as pd
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
import seaborn as sns
|
6 |
+
import time
|
7 |
+
|
8 |
+
df = pd.read_csv('bank.csv')
|
9 |
+
st.set_page_config(page_title='Real time dashboard',
|
10 |
+
page_icon = '✅',layout="wide")
|
11 |
+
|
12 |
+
#DASHBOARD TITLE
|
13 |
+
st.title('Real time dashbord analysis')
|
14 |
+
#filtre sur le type de job
|
15 |
+
job_filter = st.selectbox('select a job',pd.unique(df['job']))
|
16 |
+
df = df[df['job']== job_filter]
|
17 |
+
|
18 |
+
#Creation d indicateurs
|
19 |
+
avg_age = np.mean(df['age'])
|
20 |
+
count_married = int(df[(df['marital'] == 'married')]['marital'].count())
|
21 |
+
balance = np.mean(df['balance'])
|
22 |
+
|
23 |
+
kpi1,kpi2,kpi3= st.columns(3)
|
24 |
+
kpi1.metric(label='Age ⏳',value=round(avg_age),delta=round(avg_age))
|
25 |
+
kpi2.metric(label='Married Count 💍', value=count_married,
|
26 |
+
delta= round(count_married))
|
27 |
+
kpi3.metric(label='Balance $',value=f'$ {round(balance,2)}',
|
28 |
+
delta = round(balance/count_married)*100)
|
29 |
+
#Graphiques
|
30 |
+
col1,col2 = st.columns(2)
|
31 |
+
with col1:
|
32 |
+
st.markdown('### First chart')
|
33 |
+
fig1 = plt.figure()
|
34 |
+
sns.barplot(data=df,x='marital',y='age',palette='muted')
|
35 |
+
st.pyplot(fig1)
|
36 |
+
with col2:
|
37 |
+
st.markdown('### Second chart')
|
38 |
+
fig2 = plt.figure()
|
39 |
+
sns.histplot(data=df,x='age',palette='muted')
|
40 |
+
st.pyplot(fig2)
|
41 |
+
st.markdown('### Detailed data view')
|
42 |
+
st.dataframe(df)
|
43 |
+
|
44 |
+
|
45 |
+
|