Chapter 2 · Section 2 practice
Data Quality: Audit, Repair and Selection
These questions review the examples in the companion slides. Choose an answer, then check the explanation.
Question 1
What does df.isna().sum() report by default?
- Missing-value counts for each column
- The number of complete rows
- The column means
- Only repeated observations
Question 2
What does df.dropna(subset=["price"]) retain?
- Only rows with every column observed
- Only columns without missing values
- Rows where price is missing
- Rows with an observed price, regardless of missing values in other columns
Question 3
In time-sorted data, which replacement uses the preceding observed value?
fillna(0)dropna()ffill()bfill()
Question 4
Two timestamps each appear twice. How many rows does index.duplicated(keep=False) mark?
- 1
- 4
- 2
- 0
Question 5
Which expression keeps rows with price strictly between 10 and 20?
df.loc[(df["price"] > 10) & (df["price"] < 20)]df.loc[df["price"] > 10 & df["price"] < 20]df.loc[df["price"] > 20]df.loc[df["price"] < 10]
Question 6
A column has a five-month gap. What should happen before replacing it with a constant?
- Fill it because every gap must be removed
- Assume all missing values are zero
- Delete every column in the dataset
- Inspect the source, gap and effect of the proposed replacement