runtime
447 / 500
question 447 Data Formats & Analytical Workflows · medium

A seeded sample of flights per airline

An audit reviews up to per_airline flights from each airline. Write audit_flights(flights, per_airline, seed): from each airline take per_airline flights at random with sample(n=..., random_state=seed), or all of its flights if it has fewer, and return those rows ordered by flight_id. The same seed must always give the same rows.

Functionaudit_flights(flights, per_airline, seed)
Returnsa DataFrame with the same columns, rows ordered by flight_id

Loading your progress…

A seeded sample of flights per airline — Python practice · Runtime