Data Transformation
Kettle & Crumb opens a second branch, and its till exports data its own way: dates like 03/06/2025 stored as text, prices in paise, and a column called Qty Sold. You cannot stack the two tables, compare the branches, or chart them together until they speak the same language. Transformation is the step that makes values consistent and comparable.
The rule
Same meaning, same form: standardise, derive, then rescale.
1. Standardise so that equal things look equal:
- Types: text that looks like a date or number becomes a real date or number.
- Formats: one date format (
2025-06-03), one spelling for categories (Cold coffee, notcold coffeeandCold Coffee). - Units: one currency and scale. 12,000 paise ÷ 100 = ₹120.
- Names: matching column names, such as
qtyin both tables.
2. Derive new columns from existing ones:
weekdayfromorder_date, to compare weekends with weekdays.revenue = qty × price.- Bins: turning a number into bands, like order size
Small / Medium / Large. branch, added before stacking two tables, so each row keeps its origin.
3. Rescale when numbers on different scales must be compared:
- Min-max scaling squeezes a column into 0 to 1: (x − min) ÷ (max − min).
- z-scores say how many standard deviations a value is from the mean: (x − mean) ÷ standard deviation. For the week's sales (mean 48, standard deviation 21), a day of 69 cups has z = 1.
- Aggregation, such as daily rows summed to weekly totals, is also a transformation: it changes the level of detail.