-
Notifications
You must be signed in to change notification settings - Fork 0
/
Analysis.py
178 lines (143 loc) · 9.55 KB
/
Analysis.py
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import streamlit as st
import streamlit as st
import pandas as pd
from streamlit_extras.colored_header import colored_header
from streamlit_extras.let_it_rain import rain
import plotly.express as px
def app():
colored_header(
label = 'You are in Data :green[Analysis] page',
color_name = 'green-70',
description = ''
)
@st.cache_data
def dataframe():
df = pd.read_csv('Cleaned_Store_data.csv')
df1 = pd.read_csv('Cleaned_Store_data2.csv')
return df,df1
df,df1 = dataframe()
choice = st.selectbox("**Select an option to Explore their data**", (['Explore of Weekly Sales','Explore of Markdown']))
if choice == 'Explore of Weekly Sales':
st.markdown("## :rainbow[Stores and their sum of Weekly Sales]")
sales = df.groupby(['Store'])['Weekly_Sales','Markdown'].sum().reset_index()#.sort_values('Weekly_Sales',ascending=False).head(10)
# st.dataframe(sales)
st.bar_chart(sales, x = 'Store', y = ['Weekly_Sales'],color = 'Markdown')
st.markdown("## :rainbow[Top 10 Store has Highest Sales]")
highest_sale = df.groupby(['Store'])['Weekly_Sales'].sum().reset_index().sort_values('Weekly_Sales',ascending=False).head(10)
st.bar_chart(highest_sale, x = 'Store', y = 'Weekly_Sales', color = '#04f')
st.markdown("## :rainbow[Top 10 Store has Lowest Sales]")
lowest_sale = df.groupby(['Store'])['Weekly_Sales'].sum().reset_index().sort_values('Weekly_Sales',ascending=True).head(10)
st.bar_chart(lowest_sale, x = 'Store', y = 'Weekly_Sales',color = '#fd0')
st.markdown("## :rainbow[Department and their sum of Weekly Sales]")
sales = df.groupby(['Dept'])['Weekly_Sales'].sum().reset_index()#.sort_values('Weekly_Sales',ascending=False).head(10)
# st.dataframe(highest_sale)
st.bar_chart(sales, x = 'Dept', y = 'Weekly_Sales')
st.markdown("## :rainbow[Top 10 Department has Highest Sales]")
highest_sale = df.groupby(['Dept'])['Weekly_Sales'].sum().reset_index().sort_values('Weekly_Sales',ascending=False).head(10)
st.bar_chart(highest_sale, x = 'Dept', y = 'Weekly_Sales', color = '#3F00FF')
st.markdown("## :rainbow[Top 10 Department has Lowest Sales]")
lowest_sale = df.groupby(['Dept'])['Weekly_Sales'].sum().reset_index().sort_values('Weekly_Sales',ascending=True).head(10)
st.bar_chart(lowest_sale, x = 'Dept', y = 'Weekly_Sales', color = '#CCCCFF')
st.markdown("## :rainbow[Sum of weekly sales with their year]")
total_year = df.groupby('year')['Weekly_Sales'].sum().reset_index()
# st.dataframe(total_year)
pie = px.pie(total_year, values = 'Weekly_Sales',names = 'year',width=900,height=500)
st.plotly_chart(pie)
col,col1 = st.columns([2,2])
with col:
radio = st.radio('**Select a Year to Analyze with specific year**', options = df['year'].unique(), horizontal = True)
with col1:
select = st.selectbox("**Select any feature**", (['Temperature','Fuel_Price','CPI','Unemployment']))
st.markdown(f"## :rainbow[{select} vs Sales]")
data = df[df['year'] == radio]
dataframe = data.groupby(select)['Weekly_Sales'].sum().reset_index()
hist = px.histogram(dataframe, x = select,y = 'Weekly_Sales', width = 1050)
st.plotly_chart(hist)
date = st.selectbox("**Select a feature to explore periodic wise**", (['month','day','day_of_week','year_of_week']))
st.markdown(f"## :rainbow[{date} vs Sales]")
df['year_of_week'] = df1['year_of_week']
df['day_of_week'] = df['day_of_week'].map({0:'Monday',1:'Tuesday',2:'Wednesday',3:'Thursday',4:'Friday',5:'saturday',6:'Sunday'})
data = df[df['year'] == radio]
dataframe = data.groupby(date)['Weekly_Sales'].sum().reset_index()
st.bar_chart(dataframe, x = date,y = 'Weekly_Sales')
st.markdown(f"## :rainbow[Date vs Sales]")
data = df[df['year'] == radio]
date = data.groupby('Date')['Weekly_Sales','Markdown'].sum().reset_index()
line = px.line(date,x = 'Date', y = ['Weekly_Sales','Markdown'],title = 'Sum of Weekly Sales and Markdown for selected Year', width = 1000,height=600)
st.plotly_chart(line)
st.markdown(f"## :rainbow[IsHoliday and Month vs Sales for selected Year]")
data = df[df['year'] == radio]
data['IsHoliday'] = data['IsHoliday'].map({0:'False',1:'True'})
date = data.groupby(['month','IsHoliday'])['Weekly_Sales'].sum().reset_index()
# st.dataframe(date)
bar = px.bar(date, x = 'IsHoliday', y = 'Weekly_Sales', color = 'month',width = 1000)
st.plotly_chart(bar)
st.markdown(f"## :rainbow[IsHoliday vs Sales and Markdown for selected Year]")
data = df[df['year'] == radio]
data['IsHoliday'] = data['IsHoliday'].map({0:'False',1:'True'})
date = data.groupby(['month','IsHoliday','Markdown'])['Weekly_Sales'].sum().reset_index()
# st.dataframe(date)
bar = px.bar(date, x = 'IsHoliday', y = ['Weekly_Sales','Markdown'],width = 1000)
st.plotly_chart(bar)
elif choice == 'Explore of Markdown':
st.markdown("## :rainbow[Stores and their sum of Markdown]")
sales = df.groupby(['Store'])['Markdown','Weekly_Sales'].sum().reset_index()#.sort_values('Weekly_Sales',ascending=False).head(10)
# st.dataframe(sales)
st.bar_chart(sales, x = 'Store', y = 'Markdown', color = 'Weekly_Sales')
st.markdown("## :rainbow[Top 10 Store has Highest Markdown]")
highest_sale = df.groupby(['Store'])['Markdown'].sum().reset_index().sort_values('Markdown',ascending=False).head(10)
st.bar_chart(highest_sale, x = 'Store', y = 'Markdown', color = '#04f')
st.markdown("## :rainbow[Top 10 Store has Lowest Markdown]")
lowest_sale = df.groupby(['Store'])['Markdown'].sum().reset_index().sort_values('Markdown',ascending=True).head(10)
st.bar_chart(lowest_sale, x = 'Store', y = 'Markdown',color = '#fd0')
st.markdown("## :rainbow[Department and their sum of Markdown]")
sales = df.groupby(['Dept'])['Markdown','Store'].sum().reset_index()#.sort_values('Weekly_Sales',ascending=False).head(10)
# st.dataframe(highest_sale)
st.bar_chart(sales, x = 'Dept', y = 'Markdown')
st.markdown("## :rainbow[Top 10 Department has Highest Markdown]")
highest_sale = df.groupby(['Dept'])['Markdown'].sum().reset_index().sort_values('Markdown',ascending=False).head(10)
st.bar_chart(highest_sale, x = 'Dept', y = 'Markdown', color = '#3F00FF')
st.markdown("## :rainbow[Top 10 Department has Lowest Markdown]")
lowest_sale = df.groupby(['Dept'])['Markdown'].sum().reset_index().sort_values('Markdown',ascending=True).head(10)
st.bar_chart(lowest_sale, x = 'Dept', y = 'Markdown', color = '#CCCCFF')
st.markdown("## :rainbow[Sum of Markdown with their year]")
total_year = df.groupby('year')['Markdown'].sum().reset_index()
# st.dataframe(total_year)
pie = px.pie(total_year, values = 'Markdown',names = 'year',width=900,height=500)
st.plotly_chart(pie)
col,col1 = st.columns([2,2])
with col:
radio = st.radio('**Select a Year to Analyze with specific year**', options = df['year'].unique(), horizontal = True)
with col1:
select = st.selectbox("**Select any feature**", (['Temperature','Fuel_Price','CPI','Unemployment']))
st.markdown(f"## :rainbow[{select} vs Markdown]")
data = df[df['year'] == radio]
dataframe = data.groupby(select)['Markdown'].sum().reset_index()
hist = px.histogram(dataframe, x = select,y = 'Markdown', width = 1050)
st.plotly_chart(hist)
date = st.selectbox("**Select a feature to explore periodic wise**", (['month','day','day_of_week','year_of_week']))
st.markdown(f"## :rainbow[{date} vs Markdown]")
df['year_of_week'] = df1['year_of_week']
df['day_of_week'] = df['day_of_week'].map({0:'Monday',1:'Tuesday',2:'Wednesday',3:'Thursday',4:'Friday',5:'saturday',6:'Sunday'})
data = df[df['year'] == radio]
dataframe = data.groupby(date)['Markdown'].sum().reset_index()
st.bar_chart(dataframe, x = date,y = 'Markdown')
st.markdown(f"## :rainbow[Date vs Markdown]")
data = df[df['year'] == radio]
date = data.groupby('Date')['Markdown'].sum().reset_index()
line = px.line(date,x = 'Date', y = ['Markdown'],title = 'Sum of Markdown for selected Year', width = 1000,height=600)
st.plotly_chart(line)
st.markdown(f"## :rainbow[IsHoliday and Month vs Markdown for selected Year]")
data = df[df['year'] == radio]
data['IsHoliday'] = data['IsHoliday'].map({0:'False',1:'True'})
date = data.groupby(['month','IsHoliday'])['Markdown'].sum().reset_index()
# st.dataframe(date)
bar = px.bar(date, x = 'IsHoliday', y = 'Markdown', color = 'month',width = 1000)
st.plotly_chart(bar)
st.markdown(f"## :rainbow[IsHoliday vs Sales and Markdown for selected Year]")
data = df[df['year'] == radio]
data['IsHoliday'] = data['IsHoliday'].map({0:'False',1:'True'})
date = data.groupby(['month','IsHoliday','Markdown'])['Weekly_Sales'].sum().reset_index()
# st.dataframe(date)
bar = px.bar(date, x = 'IsHoliday', y = ['Weekly_Sales','Markdown'],width = 1000)
st.plotly_chart(bar)