Back to the lessonPreparing the printout…

Data Cleaning and Preprocessing with Python · Module 3 — Prepare, Report and Reproduce

Period 11 · Scaling and Encoding

[video] Lecture video — Period 11: Scaling and Encoding — /api/lesson-media/videos/4d3653ff-a3ca-4f63-bf8e-bb93c553e599-1794892498606-7e88a6b514dce6d8.mp4

[markdown] content available only on the platform

[markdown] content available only on the platform

Flashcards · Scaling and Encoding

Min-Max scaling — Rescales values to 0-1 using the observed minimum and maximum: (x - min) / (max - min).

Quantity 4 with min 2, max 8 gives 0.33.

Z-score — Distance from the mean in standard deviation units: (x - mean) / std.

Quantity 8, mean 5, std 2.24 gives 1.34.

Constant column — A column where every value is equal, so the Min-Max range is zero and needs a defined rule.

`0.0 if span == 0 else (x - x.min()) / span`

ddof=0 — Population convention for standard deviation, dividing by n instead of n - 1.

`x.std(ddof=0)` gives about 2.24 for 2, 4, 6, 8.

One-hot encoding — Represents each category of a nominal variable as its own 0/1 indicator column.

North row: region_North 1, region_South 0, region_Central 0.

pd.get_dummies() — The pandas function that creates one-hot indicator columns from a categorical column.

`pd.get_dummies(df["region"], prefix="region", dtype=int)`

Ordinal encoding — Maps ordered categories to integers following a business-defined order.

`{"Low": 0, "Medium": 1, "High": 2}`

Nominal variable — A category with no natural order, such as a region.

North, South, Central

Training-set parameters — Scaling values (min, max, mean, std) computed only on training data and reused on test data.

Fit mean and std on training rows, apply to test rows.

[pdf] Lecture slides — Period 11 (PDF) — /api/lesson-media/pdfs/4d3653ff-a3ca-4f63-bf8e-bb93c553e599-1794873725595-60984b3e7160c2cf.pdf

Data Cleaning and Preprocessing with Python · Period 11 · Scaling and Encoding · printed on November 20, 2026