File size: 627 Bytes
ffb60f4 |
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 |
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
def generate_heatmap(df: pd.DataFrame):
if df is None or df.empty:
return None
heat = np.zeros((20, 30))
for _, row in df.iterrows():
a = int(row["Suggested Aisle"])
r = int(row["Suggested Rack"])
if 1 <= a <= 20 and 1 <= r <= 30:
heat[a - 1, r - 1] += 1
plt.figure(figsize=(6, 4))
plt.imshow(heat, cmap="hot", interpolation="nearest")
plt.colorbar()
plt.title("Warehouse Heatmap")
img_path = "/tmp/heatmap.png"
plt.savefig(img_path)
plt.close()
return img_path
|