funnel_report(visited, carted, purchased) returning a dict with cart_rate (carted/visited), purchase_rate (purchased/carted) and abandonment (1 − purchase_rate), each as a percentage rounded to 1 decimal. Any zero denominator makes that metric None — division-by-zero must not crash a dashboard.funnel_report(1000, 200, 50)
{'cart_rate': 20.0, 'purchase_rate': 25.0, 'abandonment': 75.0}Each stage is a ratio of the one before.
A tiny helper pct(a, b) avoids repeating the guard.
abandonment = 100 - purchase_rate when defined.