MBG0903 commited on
Commit
ffb60f4
·
verified ·
1 Parent(s): 4f8afd1

Create heatmap.py

Browse files
Files changed (1) hide show
  1. tools/heatmap.py +26 -0
tools/heatmap.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+
5
+
6
+ def generate_heatmap(df: pd.DataFrame):
7
+ if df is None or df.empty:
8
+ return None
9
+
10
+ heat = np.zeros((20, 30))
11
+
12
+ for _, row in df.iterrows():
13
+ a = int(row["Suggested Aisle"])
14
+ r = int(row["Suggested Rack"])
15
+ if 1 <= a <= 20 and 1 <= r <= 30:
16
+ heat[a - 1, r - 1] += 1
17
+
18
+ plt.figure(figsize=(6, 4))
19
+ plt.imshow(heat, cmap="hot", interpolation="nearest")
20
+ plt.colorbar()
21
+ plt.title("Warehouse Heatmap")
22
+ img_path = "/tmp/heatmap.png"
23
+ plt.savefig(img_path)
24
+ plt.close()
25
+
26
+ return img_path