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