Skip to course content
Free course

Python Foundations / Module 9 / Missing and Invalid Values

Module 9 lesson

Missing and Invalid Values

Unit ID: M09-U03 Estimated active time: 30-40 minutes

Missing means no value is present under the source representation. Invalid means a value is present but violates the task's rule. They require different evidence.

minutes = pd.to_numeric(working["minutes"], errors="coerce")
invalid_minutes = minutes.isna() | minutes.lt(0) | minutes.gt(180)

errors="coerce" turns unparseable values into missing numeric values. Keep the original text so the rejection reason can be explained. Do not replace every invalid value with zero; zero is a real value.

For this module, a missing score is allowed for unfinished work. A non-empty score that cannot become a number is invalid.

Practice: explain how you would distinguish blank score text, not-set, zero, and 105 when allowed scores are 0 through 100.