FunctionRacerProblemsRace

Cancelled Share per Day

HardpandasPython

rides has columns id, rider, driver, day and status ("done" or "cancelled"). people has id and banned ("yes" or "no"), and holds every rider and driver.

Leave out every ride whose rider or driver is banned. For each day that still has rides, return the share of them that were cancelled, as a dict from day to share.

Example 1

rides {"id":[1,2,3,4,5],"rider":[1,2,3,1,2],"driver":[4,4,5,5,5],"day":["Mon","Mon","Mon","Tue","Tue"],"status":["cancelled","done","cancelled","done","done"]}
people {"id":[1,2,3,4,5],"banned":["no","no","yes","no","no"]}
returns {"Mon":0.5,"Tue":0.0}

Person 3 is banned, so rides 3 is left out. Monday keeps two rides, one cancelled. Tuesday keeps two, none cancelled.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More pandas problems