Debate League Standings and Divisions
Problem
A school debate league keeps each squad's season in a DataFrame `squad_records` loaded from `squad_records.csv`. Each row has a `squad_id`, a `squad_name`, the number of `rounds_debated`, and counts of `wins`, `splits`, and `losses`.
Scoring gives 3 points per win and 1 point per split; losses score nothing. For each squad compute its `squad_name`, total `score`, and `placement` — the ranking by score from highest to lowest using standard competition ranking (ties share a placement and the next placement skips positions, i.e. `rank(method="min")`). Then assign a `division` based on placement relative to the number of squads N: the top third (placement at or below CEIL(N * 0.33)) is 'Division A', the next third (placement at or below CEIL(N * 0.66)) is 'Division B', and the remainder is 'Division C'. A placement that lands exactly on a boundary goes to the higher division.
Return a DataFrame with columns `squad_name`, `score`, `placement`, `division`, ordered by `score` descending, then by `squad_name` ascending.
Input data
Example rows — the live problem includes the full dataset.
| squad_id | squad_name | rounds_debated | wins | splits | losses |
|---|---|---|---|---|---|
| 1 | Aristotle | 9 | 8 | 1 | 0 |
| 2 | Boyle | 9 | 6 | 1 | 2 |
| 3 | Curie | 9 | 5 | 2 | 2 |
| 4 | Darwin | 9 | 3 | 3 | 3 |
| 5 | Euler | 9 | 1 | 0 | 8 |
Expected output
Your answer should return 5 rows with the columns squad_name, score, placement, division.
Starter code (Pandas (Python))
import pandas as pd
def squad_standings(squad_records) -> pd.DataFrame:
# Your code here
return squad_recordsSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock