Learn/Data Analytics/Environment
IntermediateEnvironmentPYTHON+20 XP

Water quality: clean the pH readings

Scenario

You are a data analyst. A catchment monitoring programme logs pH from field probes. Some readings are impossible (below 0 or above 14) because probes drift when batteries fail.

Question

Drop invalid pH readings, fill missing turbidity with the median, and report the mean pH per site.

Intermediate · Record Counting & Average Calculations — question 11 of 30

Finish all 30 to earn a certificate

1. Choose your dataset

Pick an industry and a size. Your code and results change to match.

📓 DataPro notebookan-env-01.ipynbFileEditViewRunKernel: Python 3
[md]

Water quality: clean the pH readings

Drop invalid pH readings, fill missing turbidity with the median, and report the mean pH per site.

In [1]:

Your code cell is below. Press Check my answer to run the cell — the result appears as Out [1].

python editor
Type your code here ↓
✍️ Tap here to type

Dataset & schema

water_samples

The tiny starter data. Bigger data scrolls.

Fields

sitephturbidity_ntusample_date
Vaal-017.23.12026-02-01
Vaal-01222.92026-02-08
Klip-026.4NaN2026-02-01
Klip-026.85.22026-02-08
attempts: 0
▶ Output terminal
$ Press “Check my answer” — results appear here.

Your next steps

Each item turns green when your answer includes it.

6 left
  • Filters pH range
  • Upper pH bound
  • Fills missing turbidity
  • Uses the median
  • Groups by site
  • Takes the mean