A rate is a numerator over a denominator, and most wrong rates have the wrong denominator. Decide which rows can count before you divide:
- No-show rate: no-shows over the appointments that were due, completed plus no-shows. A cancelled appointment was called off and a scheduled one has not happened, so both stay out.
- Left without being seen: over emergency visits, not every encounter.
- Denial rate: over adjudicated claims, paid plus denied. A pending claim has no decision yet.
The mean of a True/False column is the share of Trues. So filter to the denominator, build the test, and average it by group. The share of inpatient stays that were planned, by facility:
inpatient = encounters[encounters["encounter_type"] == "inpatient"]
inpatient["planned"].groupby(inpatient["facility"]).mean()
Counting the matching rows (.size()) gives volumes, not rates. For waiting times, report the median: a few very long waits pull the mean up.