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.
The shortcut
Before combining any two sources, check type, format, unit and name for every column you will use. A mismatch in any one of them breaks a join, a sort or a sum.
Type and format
03/06/2025is text in day-month-year order. Convert it to the date 2025-06-03.
The trap is ambiguous dates. 03/06/2025 is 3 June in India and the UK but 6 March in the US. Confirm the source's convention before converting, or every month's figures shift.
Drills
Answer fast — trust the rule.
A day sells 69 cups. With the week's mean of 48 and standard deviation of 21, what is its z-score?
Using min-max scaling on the week (min 36, max 95), what does Saturday's 95 become?
Branch 2 records an amount of 22,000 paise. What is it in rupees?
You want to compare weekend and weekday sales. Which transformation helps most?
A US supplier's file has 04/07/2025. Read with the US convention, which date is it?
Remember
- Same meaning, same form: standardise, derive, then rescale.
- Shortcut: check type, format, unit and name before combining sources.
- Trap: ambiguous dates; confirm day-first or month-first before converting.
