Lists, Series, NumPy, SciPy, Matplotlib
Chapter 1 · Introduction to Business Analytics
Lists · pandas Series · NumPy · SciPy · Matplotlib
Prof. Xuhu Wan
ISOM, HKUST Business School · Wan Academy · 2026 Edition
The Python data-science stack evolved in layers, each solving a problem the previous one could not:
By the end of this chapter, you can build a working restaurant performance analyser from scratch using all four.
Tip
Why this matters. Netflix’s recommender, Foodpanda’s dispatch system, every operations team’s analytics pipeline — all run on these same four libraries.
| Section | Concept | Tool |
|---|---|---|
| 1 | Lists & indexing | Python built-in |
| 2 | List comprehensions | Python built-in |
| 3 | pandas Series | pandas |
| 4 | Descriptive statistics | pandas |
| 5 | NumPy arrays | numpy |
| 6 | Random simulation | numpy.random |
| 7 | Plotting | matplotlib |
| 8 | Probability & SLA thresholds | scipy.stats |
Your first data container.
Note
Positive indices count from the start (0, 1, 2…). Negative indices count from the end (-1, -2…). Slicing is half-open: [1:3] returns positions 1 and 2.
Doing more with one line.
Labelled 1D arrays with built-in statistics.
Note
A pandas Series = a NumPy array + an index (the labels) + a name (the column header). Each row keeps its label through every operation.
Important
.describe() gives the 8-number summary in one line. It is the single most useful first-look method for any quantitative column.
ddof=1 vs ddof=0 Trappandas defaults to sample standard deviation (divide by n−1);
NumPy defaults to population standard deviation (divide by n).
Warning
Rule of thumb. Leave pandas’ .std() at its default — sample std (ddof=1) is what every statistics textbook and Excel’s STDEV.S use.
Vectorised math at C speed.
Important
A Python list * operator means concatenate. A NumPy array * operator means element-wise multiplication. Mistaking them is the most common bug when moving from lists to NumPy.
Note
NumPy delegates math to BLAS/LAPACK — the same compiled C/Fortran libraries that run MATLAB and Bloomberg risk engines. The Python interpreter never touches the inner loop.
A 100-day simulation in three lines: draw daily steps from N(8500, 1500²), summarise, count goal-hit days.
Tip
Replace the seed(42) line and re-run to see a different person’s step pattern. Wearable-device teams run thousands of such simulations to tune daily-goal notifications.
Distributions, CDFs, and service-level thresholds.
CDF: value → probability
\[P(X < x) = \text{cdf}(x)\]
84.1 % of outcomes from N(8, 2²) fall below 10.
The PPF is the mathematical inverse of the CDF. Together they let you answer every probability question about a normal random variable.
Important
95 % SLA = “95 % of orders arrive within this time.” A single number every logistics ops team reports daily, used to staff couriers and trigger alerts.
Restaurant performance analyser in 20 lines.
Tip
Twenty lines combine everything you’ve seen: lists, comprehensions, zip, f-strings, pd.Series, and a managerial classification rule. The same logical pipeline a junior analyst at a restaurant chain assembles for a weekly menu review.
Same descriptive statistics you just learned — now applied to the music industry rather than equity prices.
An AI copilot suggests numpy.std(prices) to compute volatility. The code runs, but np.std defaults to ddof=0 (population) — you almost certainly wanted ddof=1 (sample). The code is correct; the assumption is wrong, and the AI will not flag it.
ddof, axis, and skipna defaults it used, and whether they match your data.Warning
Summer 2020. Covid forced OfQual (UK exam regulator) to cancel in-person A-level exams. They replaced them with a statistical algorithm that combined each teacher’s predicted grade with the school’s historical grade distribution. The algorithm downgraded roughly 40% of teacher predictions, and the damage fell hardest on disadvantaged schools — because those schools had lower historical means, every individual student was pulled down toward that mean, regardless of their own ability.
Lesson: descriptive statistics computed at the group level (a school’s mean, a sector’s volatility) cannot fairly score individuals. Aggregates describe distributions, not people. Always ask: what is the unit of analysis, and does my statistic respect it?
You are a junior analyst at JYP Entertainment. The 20-day stream series above is for a debut track. A&R wants to know whether to spend extra marketing budget in week 3.
To: JYP Entertainment, A&R Team From:
, junior analyst Subject: Hold the additional comeback push in week 3 Date: 2026-05-15 Recommendation: Do not allocate the extra marketing budget — track is within expected variance.
Evidence: - 20-day mean: 11.6 M streams/day; sample std: 2.5 M. - 95% VaR-style lower band ≈ 6.7 M/day → tail risk acceptable. - 20-day trend ≈ flat (+0.05 M/day, not significant).
Caveats: - Assumes future days drawn from the same distribution. - 20-day window short; weekly seasonality may dominate.
Next step: Re-run with 60 days plus ARIMA before any budget decision.
| Concept | Tool | Use |
|---|---|---|
| Ordered collection | list |
Menu items, daily logs |
| Concise transform | comprehension | On-time / Late labels |
| Labelled 1D | pd.Series |
Daily check-ins, streams |
| Fast vector math | np.array |
Monte Carlo, step counts |
| Probability | scipy.stats.norm |
SLA thresholds, hypothesis tests |
| Charts | matplotlib |
Histograms, lines |
Next: Chapter 2 — DataFrames (Series side-by-side; the actual workhorse of every analytical pipeline).
std() to n−1 while NumPy defaults to n? What would happen if an ops team computed a 95 % SLA using n instead of n−1 on a small sample?Prof. Xuhu Wan · HKUST ISOM · Introduction to Business Analytics