-
Notifications
You must be signed in to change notification settings - Fork 1
/
dashboard.py
284 lines (273 loc) · 10.5 KB
/
dashboard.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
import numpy as np
import pandas as pd
import squarify
import matplotlib
import matplotlib.pyplot as plt
import datapane as dp
# Volumes per day
df_day = pd.read_csv('data/volumes per day.csv')
# Bar Plot: Orders/Lines
orderlines = ([dp.Plot(df_day[df_day['WEEK'] ==wk].plot.bar(figsize=(8, 6), edgecolor='black', x='DAY', y=['ORDERS', 'LINES'], color=['tab:blue', 'tab:red'], legend= True),
label = wk)
for wk in df_day['WEEK'].unique()])
plt.xlabel('DAY', fontsize = 12)
plt.title('Workload per day (Lines/day)', fontsize = 12)
plt.show()
# Bar Plot: Lines/Pcs
linespcs = ([dp.Plot(df_day[df_day['WEEK'] ==wk].plot.bar(figsize=(8, 6), edgecolor='black', x='DAY', y=['LINES', 'PCS'],
color=['tab:orange', 'tab:green'], legend= True),
label = wk)
for wk in df_day['WEEK'].unique()])
plt.xlabel('DAY', fontsize = 12)
plt.title('Volumes per day (Pieces/day)', fontsize = 12)
plt.show()
# Line Plot: Cities Delivered
cities = df_day.plot(figsize=(10, 6),
x='DATE', y='CITIES', color=['darkblue'], legend= True)
plt.xlabel('DAY', fontsize = 12)
plt.axhline(y = df_day['CITIES'].mean(), color = 'red', linestyle='--')
plt.title('Cities delivered per day', fontsize = 12)
plt.show()
# Lines per Order Split
df_lior = pd.read_csv('data/lines per order.csv', index_col = 0)
df_lior.reset_index(inplace = True)
COLS_IN = list(df_lior.columns[2:8])
# Bar Plot: split per lines per orders
lines_orders = df_lior.plot.bar(figsize=(10, 6), edgecolor='black', x='WEEK', y=COLS_IN[0], color='tab:blue', legend= True)
df_lior.plot.bar(figsize=(10, 6), edgecolor='black', x='WEEK', y=COLS_IN[1], color='tab:red', legend= True, ax = lines_orders)
df_lior.plot.bar(figsize=(10, 6), edgecolor='black', x='WEEK', y=COLS_IN[2], color='tab:orange', legend= True, ax = lines_orders)
df_lior.plot.bar(figsize=(10, 6), edgecolor='black', x='WEEK', y=COLS_IN[3], color='darkblue', legend= True, ax = lines_orders)
df_lior.plot.bar(figsize=(10, 6), edgecolor='black', x='WEEK', y=COLS_IN[4], color='brown', legend= True, ax = lines_orders)
df_lior.plot.bar(figsize=(10, 6), edgecolor='black', x='WEEK', y=COLS_IN[5], color='grey', legend= True, ax = lines_orders)
plt.xlabel('Week', fontsize = 12)
plt.ylabel('Number of Orders', fontsize = 12)
plt.title('Split of orders by number of lines/order', fontsize = 12)
plt.show()
# Pareto Analysis
df_pareto = pd.read_csv('data/pareto.csv', index_col = 0)
WEEKS = df_day['WEEK'].unique()
# Line Plot
paretoplot1 = df_pareto.plot(figsize=(12, 7), y=WEEKS[0], color='tab:orange', legend = False)
plt.xlabel('Number of SKU', fontsize = 12)
plt.title('Pareto of Sales (%SKU)', fontsize = 12)
plt.axhline(y = 80, color = 'black', linestyle='--')
plt.axvline(x = 20, color = 'blue', linestyle='--')
plt.axvline(x = df_pareto[df_pareto[WEEKS[0]]>80].index[0], color = 'black', linestyle='--')
plt.xlabel('SKU (%)')
plt.ylabel('PCS (%)')
plt.show()
# Line Plot
paretoplot2 = df_pareto.plot(figsize=(12, 7), y=WEEKS[1], color='black', legend = False)
plt.xlabel('Number of SKU', fontsize = 12)
plt.title('Pareto of Sales (%SKU)', fontsize = 12)
plt.axhline(y = 80, color = 'black', linestyle='--')
plt.axvline(x = 20, color = 'blue', linestyle='--')
plt.axvline(x = df_pareto[df_pareto[WEEKS[1]]>80].index[0], color = 'black', linestyle='--')
plt.xlabel('SKU (%)')
plt.ylabel('PCS (%)')
plt.show()
# Line Plot
paretoplot3 = df_pareto.plot(figsize=(12, 7), y=WEEKS[2], color='tab:purple', legend = False)
plt.xlabel('Number of SKU', fontsize = 12)
plt.title('Pareto of Sales (%SKU)', fontsize = 12)
plt.axhline(y = 80, color = 'black', linestyle='--')
plt.axvline(x = 20, color = 'blue', linestyle='--')
plt.axvline(x = df_pareto[df_pareto[WEEKS[2]]>80].index[0], color = 'black', linestyle='--')
plt.xlabel('SKU (%)')
plt.ylabel('PCS (%)')
plt.show()
# Line Plot
paretoplot4 = df_pareto.plot(figsize=(12, 7), y=WEEKS[3], color='tab:blue', legend = False)
plt.xlabel('Number of SKU', fontsize = 12)
plt.title('Pareto of Sales (%SKU)', fontsize = 12)
plt.axhline(y = 80, color = 'black', linestyle='--')
plt.axvline(x = 20, color = 'blue', linestyle='--')
plt.axvline(x = df_pareto[df_pareto[WEEKS[3]]>80].index[0], color = 'black', linestyle='--')
plt.xlabel('SKU (%)')
plt.ylabel('PCS (%)')
plt.show()
# Line Plot
paretoplot5 = df_pareto.plot(figsize=(12, 7), y=WEEKS[4], color='tab:green', legend = False)
plt.xlabel('Number of SKU', fontsize = 12)
plt.title('Pareto of Sales (%SKU)', fontsize = 12)
plt.axhline(y = 80, color = 'black', linestyle='--')
plt.axvline(x = 20, color = 'blue', linestyle='--')
plt.axvline(x = df_pareto[df_pareto[WEEKS[4]]>80].index[0], color = 'black', linestyle='--')
plt.xlabel('SKU (%)')
plt.ylabel('PCS (%)')
plt.show()
# Number of replenishments
df_repcount = pd.read_csv('data/replenishments.csv', index_col = 0)
# Bar Plot
repldays = ([dp.Plot(df_repcount.plot.bar(figsize=(8, 6), edgecolor='blue', y=wk, color=['tab:green'], legend= True),
label = wk)
for wk in df_day['WEEK'].unique()])
plt.xlabel('DAY', fontsize = 12)
plt.title('Number of Replenishments per day', fontsize = 12)
plt.show()
# Replenishments per Picking Cell
df_repl = pd.read_csv('data/replenishments details.csv')
dict_color = dict(zip(['A06', 'A07', 'A05', 'A04', 'A02', 'R04', 'A03', 'A01', 'A08','R05', 'A09', 'A10', 'A11', 'H02', 'B03', 'R06'],
['blue', 'red', 'yellow', 'orange', 'brown', 'cyan', 'tab:blue', 'tab:red', 'lightblue', 'tab:orange', 'grey', 'tab:green', 'purple', 'darkblue', 'white', 'magenta']))
# Treemap 1
wk = df_day['WEEK'].unique()[0]
df_plot = df_repl[df_repl[wk]>0][['Alley', wk]].copy()
df_plot = pd.DataFrame(df_plot.groupby(['Alley'])[wk].sum())
df_plot['%'] = (100*df_plot[wk]/df_plot[wk].sum()).round(2)
df_plot.reset_index(inplace = True)
df_plot['LABEL'] = df_plot[['Alley','%']].apply(lambda t: t['Alley'] +'\n' + str(t['%']) + '%', axis = 1)
plt.figure(figsize=(15, 12))
tree_map1 = squarify.plot(sizes = df_plot[wk], color=df_plot['Alley'].map(dict_color)
, label = df_plot['LABEL']
, edgecolor="#222222", text_kwargs={'fontsize':12})
plt.axis('on')
plt.title('Number of Replenishments per Picking Cell' +'\n', fontsize=12)
tree_map1.axes.xaxis.set_visible(False)
tree_map1.axes.yaxis.set_visible(False)
plt.show()
del df_plot
# Treemap 2
wk = df_day['WEEK'].unique()[1]
df_plot = df_repl[df_repl[wk]>0][['Alley', wk]].copy()
df_plot = pd.DataFrame(df_plot.groupby(['Alley'])[wk].sum())
df_plot['%'] = (100*df_plot[wk]/df_plot[wk].sum()).round(2)
df_plot.reset_index(inplace = True)
df_plot['LABEL'] = df_plot[['Alley','%']].apply(lambda t: t['Alley'] +'\n' + str(t['%']) + '%', axis = 1)
plt.figure(figsize=(15, 12))
tree_map2 = squarify.plot(sizes = df_plot[wk], color=df_plot['Alley'].map(dict_color)
, label = df_plot['LABEL']
, edgecolor="#222222", text_kwargs={'fontsize':12})
plt.axis('on')
plt.title('Number of Replenishments per Picking Cell' +'\n', fontsize=12)
tree_map2.axes.xaxis.set_visible(False)
tree_map2.axes.yaxis.set_visible(False)
plt.show()
del df_plot
# Treemap 3
wk = df_day['WEEK'].unique()[2]
df_plot = df_repl[df_repl[wk]>0][['Alley', wk]].copy()
df_plot = pd.DataFrame(df_plot.groupby(['Alley'])[wk].sum())
df_plot['%'] = (100*df_plot[wk]/df_plot[wk].sum()).round(2)
df_plot.reset_index(inplace = True)
df_plot['LABEL'] = df_plot[['Alley','%']].apply(lambda t: t['Alley'] +'\n' + str(t['%']) + '%', axis = 1)
plt.figure(figsize=(15, 12))
tree_map3 = squarify.plot(sizes = df_plot[wk], color=df_plot['Alley'].map(dict_color)
, label = df_plot['LABEL']
, edgecolor="#222222", text_kwargs={'fontsize':12})
plt.axis('on')
plt.title('Number of Replenishments per Picking Cell' +'\n', fontsize=12)
tree_map3.axes.xaxis.set_visible(False)
tree_map3.axes.yaxis.set_visible(False)
plt.show()
del df_plot
# Treemap 4
wk = df_day['WEEK'].unique()[3]
df_plot = df_repl[df_repl[wk]>0][['Alley', wk]].copy()
df_plot = pd.DataFrame(df_plot.groupby(['Alley'])[wk].sum())
df_plot['%'] = (100*df_plot[wk]/df_plot[wk].sum()).round(2)
df_plot.reset_index(inplace = True)
df_plot['LABEL'] = df_plot[['Alley','%']].apply(lambda t: t['Alley'] +'\n' + str(t['%']) + '%', axis = 1)
plt.figure(figsize=(15, 12))
tree_map4 = squarify.plot(sizes = df_plot[wk], color=df_plot['Alley'].map(dict_color)
, label = df_plot['LABEL']
, edgecolor="#222222", text_kwargs={'fontsize':12})
plt.axis('on')
plt.title('Number of Replenishments per Picking Cell' +'\n', fontsize=12)
tree_map4.axes.xaxis.set_visible(False)
tree_map4.axes.yaxis.set_visible(False)
plt.show()
del df_plot
# Treemap 5
wk = df_day['WEEK'].unique()[4]
df_plot = df_repl[df_repl[wk]>0][['Alley', wk]].copy()
df_plot = pd.DataFrame(df_plot.groupby(['Alley'])[wk].sum())
df_plot['%'] = (100*df_plot[wk]/df_plot[wk].sum()).round(2)
df_plot.reset_index(inplace = True)
df_plot['LABEL'] = df_plot[['Alley','%']].apply(lambda t: t['Alley'] +'\n' + str(t['%']) + '%', axis = 1)
plt.figure(figsize=(15, 12))
tree_map5 = squarify.plot(sizes = df_plot[wk], color=df_plot['Alley'].map(dict_color)
, label = df_plot['LABEL']
, edgecolor="#222222", text_kwargs={'fontsize':12})
plt.axis('on')
plt.title('Number of Replenishments per Picking Cell' +'\n', fontsize=12)
tree_map5.axes.xaxis.set_visible(False)
tree_map5.axes.yaxis.set_visible(False)
plt.show()
del df_plot
# # Plot Orders Lines per day
# dp.Report(
# dp.Page(
# dp.Select(blocks = orderlines)
# )
# ).upload(name='orders/lines per day')
# # Plot Pieces per day
# dp.Report(
# dp.Page(
# dp.Select(blocks = linespcs)
# )
# ).upload(name='pieces per day')
# # Cities delivered per day
# dp.Report(
# dp.Page(
# title="Page 1",
# blocks=[ cities]
# )
# ).upload(name='cities per day')
# # Lines per order
# dp.Report(
# dp.Page(
# title="Page 1",
# blocks=[ lines_orders]
# )
# ).upload(name='lines per order')
# dp.Report(
# dp.Page(
# title="WEEK-1",
# blocks=[paretoplot1]
# ),
# dp.Page(
# title="WEEK-2",
# blocks=[paretoplot2]
# ),
# dp.Page(
# title="WEEK-3",
# blocks=[paretoplot3]
# ),
# dp.Page(
# title="WEEK-4",
# blocks=[paretoplot4]
# ),
# dp.Page(
# title="WEEK-5",
# blocks=[paretoplot5]
# )
# ).upload(name='pareto analysis')
# # Plot Replenishments
# dp.Report(
# dp.Page(
# dp.Select(blocks = repldays)
# )
# ).upload(name='replenishments per day')
# Replenishment per cell
dp.Report(
dp.Page(
title="WEEK-1",
blocks=[tree_map1]
),
dp.Page(
title="WEEK-2",
blocks=[tree_map2]
),
dp.Page(
title="WEEK-3",
blocks=[tree_map3]
),
dp.Page(
title="WEEK-4",
blocks=[tree_map4]
),
dp.Page(
title="WEEK-5",
blocks=[tree_map5]
)
).upload(name='treemap replenishment')