Connect the steps and explain the result to another engineer.
Each week supplied part of this workflow: represent a value, apply a rule, process observations, write reusable calculations, handle failures and save the result.
The project supplies 20 records from temperature, humidity and pressure sensors. Build the existing sensor-log summary using these records and the stated validation rules.
Start with the problem
Try this first.
Choose one valid record and one faulty record from the supplied file. Sketch where each should go: read → validate → group → summarise → save. Decide how you will check the result.
Why this week's tool?
Use the Python tools you already know to connect the stages. The main work is agreeing on their inputs and outputs and checking that information survives each step.
By the end: Walk another person through the cleaned CSV, summary and one handled fault. Explain one limitation of the result using evidence from your own run.
The idea behind the program
Connect the contracts
The input schema is timestamp,sensor,value. Read → validate → group → summarize → save. Each stage should have a clear input and output so a discrepancy can be localized. Validate structure, known sensor, timestamp, numeric conversion, finiteness and the sensor-specific range.
Use independent reference checks
The supplied fixture has 15 retained and 5 rejected records. Temperature has 6 readings with mean 23.02 °C; humidity has 5 with mean 45.38%; pressure has 4 with mean 1012.86 hPa. These are reference results for the supplied file, not targets to hard-code.
A clean report has limits
A 75% retained-row rate describes your validation policy on this file. It is not a sensor-accuracy score or proof that the machine is healthy. Valid-range data can still contain bias, stale readings or a swapped sensor label.
Explain the empty case
If a sensor has no valid values, display count 0 and N/A for statistics. Do not call min() on an empty group or substitute zero. Keep units separate; comparing temperature and pressure means numerically has no shared physical meaning.
A short Python example
Read the example alongside the explanation. Run it in a new notebook cell and change one input to see how it behaves.
Temperature mean: 23.02 C
Retained-row rate: 75.0%
This short cell is an independent arithmetic check, not the pipeline implementation. Build and test the complete program through notebook milestones EX01–EX10. Teaching acceptance ranges are temperature −50–60 °C, humidity 0–100%, and pressure 800–1200 hPa, all inclusive.
The report needs a chain of explainable contracts
The sensor project composes reading, validation, grouping, summarising and writing. Each stage must state its accepted input, output and failure policy. A plausible final average cannot establish that the entire pipeline is correct.
Draw or trace
Draw a pipeline and track four rows: T1=10, T1=20, T1=missing and T2=30, with compatible units and values allowed by the sensor contracts. Keep accepted and rejected counts beside the flow.
Predict before running. What should T1’s count and mean be? Can sorting, dropping duplicates or replacing the missing value with zero silently change the answer?
Trace and explanation — after your prediction
Validation accepts three numeric rows and rejects the missing one with a reason.
T1 has count 2, sum 30 and mean 15; T2 has count 1 and mean 30.
An independent hand summary of these tiny inputs checks the full pipeline’s output.
Preserve raw data and distinguish per-sensor results from the total accepted-row count. Repeated equal readings may be legitimate observations. Explain the all-invalid case and check the reopened report.
Change one thing. AA asks the next question: can repeated per-sensor scans and a single-pass dictionary compute exactly this same result, and how does their work grow? That comparison is optional here; CP1 first establishes reliable behaviour.
Türkçe: Her aşamanın girdi, çıktı ve hata kuralını belirt. Küçük veriyi elle özetleyerek bütün hattı kontrol et; makul görünen sonuç tek başına kanıt değildir.
Examples and variations
Each example changes something about the same problem. Open the ones you want to explore and follow the worked explanation.
01Supplied fixture
20 records; 15 retained; 5 rejected; temperature sum 138.1 over 6 readings
Question: Predict the retained-row rate and displayed temperature mean.
15 / 20 × 100 = 75%
138.1 / 6 = 23.0166…
Display temperature mean as 23.02 °C
75.0% retained; temperature mean 23.02 °C
These checks test counts and arithmetic. They do not replace checking each rejected row and the saved output.
02Empty sensor group
After validation, pressure has no retained values
Question: What should count, min, max and mean show?
Count = 0
No values exist for min or max
Mean has no valid denominator
Count 0; min/max/mean N/A
An explicit absence is a legitimate result. A numeric zero would invent a pressure measurement.
03Plausible sensor bias
Add 5 °C to every valid temperature in the supplied fixture
Question: Will range validation necessarily detect this bias?
Original valid temperatures span 22.2–24.0 °C
Shifted values span 27.2–29.0 °C, still inside −50–60
Mean shifts from 23.0166… to 28.0166… °C
Range checks pass; displayed mean becomes 28.02 °C
A plausible value is not necessarily an accurate measurement. Investigating bias needs independent evidence such as a reference sensor.
See the Colab code run
Interactive walkthroughs of Mini Project — Sensor Log Summary. Enable JavaScript to step through code, variables, collections and output. The companion notebook remains available below.
Work on it in Colab
Use the notebook to try the ideas yourself. The steps below connect this week's example to the programming practice.
State the input schema, sensor ranges, timestamp rule and output filenames. Use the supplied dataset setup in EX01.
Complete EX02–EX10 as connected milestones. At each boundary, inspect a small intermediate result before continuing.
Verify 20 = 15 + 5 and the per-sensor counts 6, 5 and 4. Check the temperature sum by hand, then reopen sensor_data_clean.csv and sensor_report.txt.
In a copy of the input, inject one fault: an unknown sensor, nonfinite value, malformed timestamp or an empty sensor group. Predict the outcome before running.
Re-run the full program in a fresh runtime, then give a three-minute handover: claim, evidence, failure handled and remaining limitation.
Something to take away: sensor_data_clean.csv, sensor_report.txt, a rejection record, and a brief handover explaining one independent check and one deliberately injected fault.
Use the notebook's core and optional labels to choose your workload. This activity fits within guided class time.
Optional notes & guidance
My notes
Notes stay in this browser. Download a copy to keep them.
Using AI or working with a partner
Use AI to propose or review individual stages. Keep a record of one suggestion you accepted or corrected and the evidence behind that decision. During practice, ask it to generate adversarial input, then establish the expected outcome yourself. Follow the instructor's AI rules for exams.
You can also review the supplied example with a partner. Use the same inputs to compare the reasoning. Follow the syllabus rules for assessed work.