AnalystPath

Chess Club Ladder Standings

PandasMediumMid level~10 min

Problem

You are given two DataFrames. `clubs` (from `clubs.csv`) has columns `club_id` and `club_name`. `bouts` (from `bouts.csv`) has columns `bout_id`, `white_club`, `black_club`, `white_wins`, and `black_wins`; each row is a team match where the two clubs played White and Black and won the listed number of boards.

Score each club across all bouts: a club earns **3 points** for winning a bout (more boards won than the opponent), **1 point** for a tie, and **0 points** for a loss. A club that played no bouts has 0 points. Return `club_id`, `club_name`, and `standing_points`, sorted by `standing_points` descending, then `club_id` ascending.

Input data

Example rows — the live problem includes the full dataset.

clubs
club_idclub_name
10Knight Owls
20Rook Riders
30Bishop Brigade
40Pawn Stars
50Castle Crew
bouts
bout_idwhite_clubblack_clubwhite_winsblack_wins
1102030
2301022
3105051
4203010
5503010

Expected output

Your answer should return 5 rows with the columns club_id, club_name, standing_points.

Starter code (Pandas (Python))

import pandas as pd

def ladder_standings(clubs, bouts) -> pd.DataFrame:
    # Your code here
    return clubs

Solve 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

Related Pandas questions