File size: 1,839 Bytes
a165792
 
30abd55
0fd081b
30abd55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pandas as pd
import streamlit as st
import plotly.express as px


st.set_page_config(page_title='Survey Results')
st.header('Survey Results')
st.subheader('the results of amount data')

# load dataframe
excel_file = 'complete_loan.xlsx'
sheet_name = 'completedloan'

df = pd.read_excel(excel_file,
                   sheet_name=sheet_name,
                   usecols='A:L',
                   header=0)

df_participants = pd.read_excel(excel_file,
                                sheet_name=sheet_name,
                                usecols='S:T',
                                header=0)

st.dataframe(df)

pie_chart = px.pie(df_participants,
                   title='Total Results',
                   values= 'participant',
                   names= 'purpose')

st.plotly_chart(pie_chart)

# streamlit selection
tujuan = df['purpose'].unique().tolist()
years = df['year'].unique().tolist()

year_selection = st.slider('year:',
                            min_value= min(years),
                            max_value= max(years),
                            value=(min(years), max(years)))

purpose_selection = st.multiselect('purpose:',
                                tujuan,
                                default=tujuan)

# filter selection
mask = (df['year'].between(*year_selection)) & (df['purpose'].isin(purpose_selection))
number_of_result = df[mask].shape[0]
st.markdown(f'*The results: {number_of_result}*')

# group data frame
df_grouped = df[mask].groupby(by=['purpose']).count()[['year']]

df_grouped = df_grouped.reset_index()

# bar chart
bar_chart = px.bar(df_grouped,
                   x= 'purpose',
                   y='year',
                   text= 'purpose',
                   color_discrete_sequence= ['black']*len(df_grouped),
                   template='plotly_white')
st.plotly_chart(bar_chart)