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%}")
Two of two App requests have scores. One of two Web requests has a score. Download image
The App mean uses both records while the Web mean uses half of its eligible records.
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]))
A Web mean interval from 2.5 through 4.5 overlaps the App mean at 4.0. Download image
The possible Web mean can fall below, equal, or rise above the App mean.
Example output
2.5 4.5
4

Official references