Heatmaps
Two dimensions at a glance.
Which product sells best on which day? That's eight products and seven days, so fifty six numbers. As a table, nobody would read it. As a heatmap, the pattern jumps out instantly.

- Eight products, seven days
- Fifty six numbers
- The pattern jumps out
A product by weekday heatmap
We build a table of average units, by product and weekday, and put the days in their proper order. Seaborn then colours each cell. Darker means more. We keep the numbers in the cells too. Run it. Straight away, you can see that Saturday and Sunday are the darkest columns, and that latte's the darkest row. A manager can use this to plan staff and stock. Use heatmaps for tables, for correlation matrices, and for retention cohorts.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sales = pd.read_csv("sales.csv", parse_dates=["date"])
sales["weekday"] = sales["date"].dt.day_name().str[:3]
t = sales.pivot_table(index="product", columns="weekday", values="units", aggfunc="mean")
t = t[["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]]
plt.figure(figsize=(8, 4.2))
sns.heatmap(t, annot=True, fmt=".0f", cmap="YlOrBr")
plt.tight_layout(); plt.savefig("heat.png", dpi=110)
print("Busiest:", t.mean().idxmax())Busiest: Sat
Summary
Colour turns a table into a picture. Your charts are now at a professional level. Next, the final push before the capstone. Getting the job.
Key takeaways- Heatmaps show two dimensions
- Keep numbers in the cells
- Great for cohorts and correlations