Measure coverage and test missing-data assumptions
Check whether a conclusion changes across groups or under different assumptions.
On this page
Compare coverage across groups
Coverage is the share of eligible rows with a usable value for a specific KPI. For feedback scores, all requests in this example are eligible. count counts valid scores, while size counts all eligible requests. Report the number of valid scores alongside any comparison of averages.
import pandas as pd
feedback = pd.DataFrame({
"channel": ["Web", "Web", "App", "App"],
"score": [4, None, 3, 5],
})
summary = feedback.groupby("channel")["score"].agg(usable="count", eligible="size")
summary["coverage"] = summary["usable"] / summary["eligible"]
for row in summary.itertuples():
print(row.Index, f"{row.usable}/{row.eligible}", f"{row.coverage:.0%}")
Download image
Example output
App 2/2 100% Web 1/2 50%
Calculate bounds when scores are missing
If the Web score scale runs from 1 to 5 and its missing value could be anywhere on that scale, the mean across both eligible requests could range from 2.5 to 4.5. The App mean is 4.0. The order of the two means can therefore change with the missing value. These are bounds under a stated assumption.
from statistics import mean
web_observed = 4
print(mean([web_observed, 1]), mean([web_observed, 5]))
print(mean([3, 5]))
Download image
Example output
2.5 4.5 4