Complete worked example
python
import pandas as pd
def inspect_example(values):
frame = pd.DataFrame({"score": pd.array(values, dtype="Float64")})
frame["missing"] = frame["score"].isna().astype("boolean")
frame["eligible"] = frame["score"].gt(0).fillna(False).astype("boolean")
return frame- Reasoning
- Construct the score column as Float64, then use isna to obtain an ordinary known missingness flag. Compare score with zero to produce a nullable boolean mask. Calling fillna(False) only on the eligibility mask says that unknown measurements do not qualify. It does not modify the original score column. Keep the missing flag and eligibility as separate boolean extension columns so their relationship can be inspected. Trace the inputs missing, zero, negative two and positive three. Their missing flags differ from their positive flags. In particular, an excluded score is not necessarily a missing score, and the output preserves that distinction.