Python Mini Projects for Beginners: 5 Practice Projects Before Learning pandas
P13.4 Python Project 4: Delivery Time Report with NumPy
Why. Operations teams ask: how fast are we, how many orders are late, which hub is slowest?
What. We store delivery minutes per hub in NumPy arrays and compute averages, late counts and the slowest hub.
How.
Build the report
- Store minutes per hub in a dictionary of arrays.
- For each hub compute mean, median and late % (> 30 min).
- Find the slowest hub by mean.
- Print a neat table.
Worked example A — Hub report.
Step 1 — What we do. Three delivery hubs in Maharashtra.
Step 2 — Type and run this code.
import numpy as np
hubs = {
"Pune": np.array([18, 22, 35, 19, 25, 41]),
"Mumbai": np.array([28, 33, 31, 26, 38, 29]),
"Nashik": np.array([15, 17, 21, 19, 16, 23]),
}
print(f"{'Hub':<8}{'Mean':>6}{'Median':>8}{'Late%':>7}")
for hub, m in hubs.items():
late = (m > 30).mean() * 100
print(f"{hub:<8}{m.mean():>6.1f}{np.median(m):>8.1f}{late:>6.0f}%")
slowest = max(hubs, key=lambda h: hubs[h].mean())
print("Slowest hub:", slowest)
Step 3 — Output you should see.
Hub Mean Median Late%
Pune 26.7 23.5 33%
Mumbai 30.8 30.0 50%
Nashik 18.5 18.0 0%
Slowest hub: Mumbai
Step 4 — What it means. (m > 30).mean() is the share of True values — a quick percentage of late orders.
Ravindra Bagale's Tip
The trick (condition).mean() gives a percentage in one step. You will use it in pandas too.
Ravindra Bagale's Tip – मराठी
(condition).mean() ही युक्ती एका step मध्ये percentage देते. pandas मध्येही वापराल.
Ravindra Bagale's Tip – हिंदी
(condition).mean() वाली trick एक step में percentage देती है. pandas में भी इस्तेमाल करोगे.