Brief
Calculate four quality measures for a batch and show why denominators and subgroups change their meaning.
Imani prepares a meeting where Voss wants to call the missing operator_id mere chance. Mara lays eight practice cards on the table: T1, T2, and T3 without operators; T4 with one; C1, C2, and two C3 rows with operators. One C3 time is unreadable. Provide exact counts and an honest conclusion before the fictional meeting. No timer limits the exercise.
Your mission
- Give overall completeness and completeness by type as fractions and percentages.
- Give time validity and explain its denominator.
- Calculate rows with IDs appearing once and freshness at 12:00 UTC.
- Apply thresholds of 95%, 95%, 100%, and 60 minutes, then conclude without accusation.
How to check your work
- Overall 5/8 = 62.5%; TRANSFER 1/4 = 25%; CHECK 4/4 = 100%.
- Seven valid times among eight received rows: 87.5%.
- Six rows with nonrepeated IDs of eight: 75%; freshness 10 min.
- Completeness, validity, uniqueness fail; freshness passes; the cause remains open.
Course example
from collections import Counter
from datetime import datetime, timedelta, timezone
rows = [
{"id": "T1", "kind": "TRANSFER", "operator_id": None, "at": "2026-04-13T09:00:00Z"},
{"id": "T2", "kind": "TRANSFER", "operator_id": None, "at": "2026-04-13T09:10:00Z"},
{"id": "T3", "kind": "TRANSFER", "operator_id": None, "at": "2026-04-13T09:20:00Z"},
{"id": "T4", "kind": "TRANSFER", "operator_id": "OP-4", "at": "2026-04-13T09:30:00Z"},
{"id": "C1", "kind": "CHECK", "operator_id": "OP-1", "at": "2026-04-13T11:00:00Z"},
{"id": "C2", "kind": "CHECK", "operator_id": "OP-2", "at": "2026-04-13T11:30:00Z"},
{"id": "C3", "kind": "CHECK", "operator_id": "OP-3", "at": "2026-04-13T11:50:00Z"},
{"id": "C3", "kind": "CHECK", "operator_id": "OP-3", "at": "bad-time"},
]
def present(row):
value = row["operator_id"]
return isinstance(value, str) and bool(value.strip())
counts = Counter(row["id"] for row in rows)
valid_times = []
for row in rows:
try:
instant = datetime.fromisoformat(row["at"].replace("Z", "+00:00"))
if instant.utcoffset() == timedelta(0):
valid_times.append(instant)
except ValueError:
pass
transfers = [row for row in rows if row["kind"] == "TRANSFER"]
checks = [row for row in rows if row["kind"] == "CHECK"]
as_of = datetime(2026, 4, 13, 12, 0, tzinfo=timezone.utc)
print(sum(1 for row in rows if present(row)), "/", len(rows))
print(sum(1 for row in transfers if present(row)), "/", len(transfers))
print(sum(1 for row in checks if present(row)), "/", len(checks))
print(len(valid_times), "/", len(rows))
print(sum(counts[row["id"]] == 1 for row in rows), "/", len(rows))
print(int((as_of - max(valid_times)).total_seconds() / 60), "minutes")