-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
120 lines (108 loc) · 5.84 KB
/
app.py
File metadata and controls
120 lines (108 loc) · 5.84 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Interactive Data Analytics Portal with Streamlit
# import libraries
import pandas as pd
import plotly.express as px
import streamlit as st
# Configuration the streamlit app (using the st.set_page_config)
st.set_page_config(
page_title='Console flare Analytics Portal',
page_icon='📊'
)
# title add (st.title) and Sub-title add (st.subheader) and (divider : use for the line colorful)
st.title(':rainbow[Data Analytics Portal]')
st.subheader(':gray[Explore Data with ease.]', divider='rainbow')
# File upload feature (st.file_uploader)
file = st.file_uploader('Drop csv or excel file', type=['csv', 'xlsx'])
if (file != None):
if (file.name.endswith('csv')):
data = pd.read_csv(file)
else:
data = pd.read_excel(file)
st.dataframe(data)
st.info('File is successfully Uploaded', icon='🚨')
#Exploring basic information
st.subheader(':rainbow[Basic information of the dataset]', divider='rainbow')
tab1, tab2, tab3, tab4 = st.tabs(['Summary', 'Top and Bottom Rows', 'Data Types', 'Columns'])
with tab1:
st.write(f'There are {data.shape[0]} rows in dataset and {data.shape[1]} columns in the dataset')
st.subheader(':gray[Statistical summary of the dataset]')
st.dataframe(data.describe())
with tab2:
st.subheader(':gray[Top Rows]')
toprows = st.slider('Number of rows you want', 1, data.shape[0], key='topslider')
st.dataframe(data.head(toprows))
st.subheader(':gray[Bottom Rows]')
bottomrows = st.slider('Number of rows you want', 1, data.shape[0], key='bottomslider')
st.dataframe(data.tail(bottomrows))
with tab3:
st.subheader(':grey[Data types of column]')
st.dataframe(data.dtypes)
with tab4:
st.subheader('Column Names in Dataset')
st.write(list(data.columns))
st.subheader(':rainbow[Column Values To Count]', divider='rainbow')
with st.expander('Value Count'):
col1, col2 = st.columns(2)
with col1:
column = st.selectbox('Choose Column name', options=list(data.columns))
with col2:
toprows = st.number_input('Top rows', min_value=1, step=1)
count = st.button('Count')
if (count == True):
result = data[column].value_counts().reset_index().head(toprows)
st.dataframe(result)
st.subheader('Visualization', divider='gray')
fig = px.bar(data_frame=result, x=column, y='count', text='count', template='plotly_white')
st.plotly_chart(fig)
fig = px.line(data_frame=result, x=column, y='count', text='count', template='plotly_white')
st.plotly_chart(fig)
fig = px.pie(data_frame=result, names=column, values='count')
st.plotly_chart(fig)
#Column value counts
st.subheader(':rainbow[Groupby : Simplify your data analysis]', divider='rainbow')
st.write('The groupby lets you summarize data by specific categories and groups')
with st.expander('Group By your columns'):
col1, col2, col3 = st.columns(3)
with col1:
groupby_cols = st.multiselect('Choose your column to groupby', options=list(data.columns))
with col2:
operation_col = st.selectbox('Choose column for operation', options=list(data.columns))
with col3:
operation = st.selectbox('Choose operation', options=['sum', 'max', 'min', 'mean', 'median', 'count'])
if (groupby_cols):
result = data.groupby(groupby_cols).agg(
newcol=(operation_col, operation)
).reset_index()
st.dataframe(result)
#Grouping data for deeper insights
st.subheader(':gray[Data Visualization]', divider='gray')
graphs = st.selectbox('Choose your graphs', options=['line', 'bar', 'scatter', 'pie', 'sunburst'])
if (graphs == 'line'):
x_axis = st.selectbox('Choose X axis', options=list(result.columns))
y_axis = st.selectbox('Choose Y axis', options=list(result.columns))
color = st.selectbox('Color Information', options=[None] + list(result.columns))
fig = px.line(data_frame=result, x=x_axis, y=y_axis, color=color, markers='o')
st.plotly_chart(fig)
elif (graphs == 'bar'):
x_axis = st.selectbox('Choose X axis', options=list(result.columns))
y_axis = st.selectbox('Choose Y axis', options=list(result.columns))
color = st.selectbox('Color Information', options=[None] + list(result.columns))
facet_col = st.selectbox('Column Information', options=[None] + list(result.columns))
fig = px.bar(data_frame=result, x=x_axis, y=y_axis, color=color, facet_col=facet_col, barmode='group')
st.plotly_chart(fig)
elif (graphs == 'scatter'):
x_axis = st.selectbox('Choose X axis', options=list(result.columns))
y_axis = st.selectbox('Choose Y axis', options=list(result.columns))
color = st.selectbox('Color Information', options=[None] + list(result.columns))
size = st.selectbox('Size Column', options=[None] + list(result.columns))
fig = px.scatter(data_frame=result, x=x_axis, y=y_axis, color=color, size=size)
st.plotly_chart(fig)
elif (graphs == 'pie'):
values = st.selectbox('Choose Numerical Values', options=list(result.columns))
names = st.selectbox('Choose labels', options=list(result.columns))
fig = px.pie(data_frame=result, values=values, names=names)
st.plotly_chart(fig)
elif (graphs == 'sunburst'):
path = st.multiselect('Choose your Path', options=list(result.columns))
fig = px.sunburst(data_frame=result, path=path, values='newcol')
st.plotly_chart(fig)