Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

Unit 9 A4: Preparing big data for analysis

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

55 minutes

A file arrives with 20,000 orders

An online shop (made up) sends you a big file of app orders. It looks ready. But one order says the buyer is 250 years old. Another has a spend of minus 8 pounds.

If you add these up as they are, your answer is wrong. Before any chart, the data must be prepared.

By the end of this lesson

Note

I can prepare a data set for analysis by checking, cleansing and coding it.

Key words

WordWhat it means
Validitydata follows the rules, such as being in range
Integritydata is complete, consistent and properly linked
Coding dataturning values into groups or short codes
Outliera value far from all the others
Cleansingfinding and fixing errors in data

The cells students fill in are left blank in this preview.

Starter: what you already know

Have a go

Starter: what you already know

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Some categories of data need more care

Analysts group data by what it is about. The group tells you what you can learn from it and how careful you must be.

Health data is the most private of all. Money data can be used to cheat people if it leaks. Environmental data, such as rain and wind, is about places and not people, so it needs the least care.

Five categories of data

CategoryExample fieldsCare needed
MedicalBlood group, conditionsHighest: only trained staff, only with permission
PersonalDate of birth, address, phoneHigh: can find one person
FinancialSalary, debt, card useHigh: can be used for fraud
EnvironmentalRain, wind, tides, sunlightLow: about places, not people
Retail habitsFavourite shops, spendMedium: shows what a person does

The cells students fill in are left blank in this preview.

Check validity and integrity first

Validity asks: does each value follow the rules? An age of 250 is out of range, so it is not valid. A spend of minus 8 is not valid.

Integrity asks: is the data whole and linked properly? Does an order point to a customer who exists? Is any order there twice? A missing town is also an integrity fault.

Try it: find the faults

Code: sql
-- Validity: ages and spends that are out of range.
SELECT order_id, age, spend FROM app_orders
WHERE age NOT BETWEEN 10 AND 100 OR spend <= 0;

-- Integrity: orders that appear more than once.
SELECT order_id, COUNT(*) AS copies FROM app_orders
GROUP BY order_id HAVING COUNT(*) > 1;

-- Integrity: orders whose customer does not exist.
SELECT app_orders.order_id, app_orders.customer_ref FROM app_orders
LEFT JOIN app_customers ON app_orders.customer_ref = app_customers.customer_ref
WHERE app_customers.customer_ref IS NULL;

-- Try: find orders with no town (town IS NULL).

The lesson goes on

7 more parts of this lesson are in the full lesson, which colleges teach from the Library. A college account gives your students all of it.