Data consistency

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Data consistency

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A student table records the house as 'Red', 'red' and 'RED'. Is this data consistent?
A No, one house is recorded in three different spellings
B Yes, they all mean the same house so it is consistent
2. Which set of dates is consistent?
A 2026-02-03, 2026-02-05, 2026-02-09
B 2026-02-03, 5/2/26, 9 Feb 2026
3. One column records distance as '5 km', '3000 m' and '2.5 km'. What is the consistency problem?
A There is no problem because every value is a distance
B The units are mixed, so the values cannot be compared directly
4. A school's enrolment system says a student is in Year 11, but the library system says Year 12. Which statement is true?
A The data is inconsistent because it disagrees across sources
B The data is consistent because each system is correct on its own
5. Which approach best keeps data consistent when many people enter a state name?
A Let everyone type it however they like
B Use a fixed list, such as a drop-down with QLD, NSW and VIC

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1df['suburb'].str.title() AConverts mixed date entries into one date format, using day-month-year order when reading them
2pd.to_datetime(df['date'], dayfirst=True) BThe same date is recorded in three formats. Pick one format, such as YYYY-MM-DD, and use it for every entry.
3Two sources must agree: a student's year level in the enrolment file should match the year level in the results file Cheight_cm = height_m * 100
4Units must be consistent: a height column mixes metres and centimetres, so every value is converted to centimetres Denrol['year'] == results['year']
5State column holds: QLD, Qld, Queensland, qld EMakes every suburb name use the same capitalisation, so 'brisbane' and 'BRISBANE' both become 'Brisbane'
6Dates in one column: 03/04/2025, 2025-04-03, 3 Apr 25 FThe same state is spelled four different ways. Choose one form, such as QLD, and use it for every record.

Definitions

Data consistency

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
city = city._____().strip()
2.
fixes = {"bne": "brisbane"} if city __ fixes: city = fixes[city]
3.
from datetime import datetime d = datetime.________(text, "%d/%m/%Y") print(d.strftime("%Y-%m-%d"))
4.
metres = _____(cm / 100, 2)
5.
__ sales != ledger: print("Sources disagree")

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A state = raw.strip().upper()
B fix = {'qld': 'Queensland'}
C state = fix.get(state, state)
D print(state)
Question 2
A for w, unit in rows:
B if unit == 'lb':
C w = w * 0.4536
D unit = 'lb'
E clean.append((w, unit))
Question 3
A a = crm_email.strip().lower()
B b = shop_email.strip().upper()
C if a != b:
D print('Mismatch')
Question 4
A for d in dates:
B parts = d.split('-')
C if len(parts[0]) != 2:
D print('Bad date', d)
Question 5
A valid = ['Red', 'Blue']
B h = row[0].strip().title()
C if h in valid:
D print('Unknown house:', h)

Answer Key

Data consistency
Section A: Quick Questions
Q1
A — No, one house is recorded in three different spellings
Q2
A — 2026-02-03, 2026-02-05, 2026-02-09
Q3
B — The units are mixed, so the values cannot be compared directly
Q4
A — The data is inconsistent because it disagrees across sources
Q5
B — Use a fixed list, such as a drop-down with QLD, NSW and VIC
Section B: Match the Pairs
Q1
df['suburb'].str.title() → Makes every suburb name use the same capitalisation, so 'brisbane' and 'BRISBANE' both become 'Brisbane'
Q2
pd.to_datetime(df['date'], dayfirst=True) → Converts mixed date entries into one date format, using day-month-year order when reading them
Q3
Two sources must agree: a student's year level in the enrolment file should match the year level in the results file → enrol['year'] == results['year']
Q4
Units must be consistent: a height column mixes metres and centimetres, so every value is converted to centimetres → height_cm = height_m * 100
Q5
State column holds: QLD, Qld, Queensland, qld → The same state is spelled four different ways. Choose one form, such as QLD, and use it for every record.
Q6
Dates in one column: 03/04/2025, 2025-04-03, 3 Apr 25 → The same date is recorded in three formats. Pick one format, such as YYYY-MM-DD, and use it for every entry.
Section C: Definitions
Q1
Data consistency — Data is consistent when the same thing is recorded in the same form (one spelling, date format and unit) and agrees everywhere it appears, including across different sources.
Section D: Fill in the Blanks
Q1
city = city.lower().strip()
Q2
fixes = {"bne": "brisbane"} if city in fixes: city = fixes[city]
Q3
from datetime import datetime d = datetime.strptime(text, "%d/%m/%Y") print(d.strftime("%Y-%m-%d"))
Q4
metres = round(cm / 100, 2)
Q5
if sales != ledger: print("Sources disagree")
Section E: Spot the Error
Q1
A — The fix dictionary uses lowercase keys, so the input must be converted with lower(). With upper(), 'QLD' never matches 'qld' and the spelling variation is not standardised.
Q2
D — After converting pounds to kilograms, the unit label must be changed to 'kg'. Keeping 'lb' means the value and its unit disagree, so the units are inconsistent. It should be unit = 'kg'.
Q3
B — Both emails must be put in the same form before comparing them across sources. Using upper() for one and lower() for the other means matching emails never compare equal. It should be lower().
Q4
C — In a YYYY-MM-DD date the first part is the year, which has 4 digits. Checking for 2 digits would flag correct dates. It should be != 4.
Q5
C — The check should flag values that are NOT in the list of agreed spellings. Using 'in' flags the correct values instead. It should be if h not in valid:.