AnalystPath

Billboard Pairs Enclosing Land

PandasMediumMid level~10 min

Problem

A survey records billboard locations on a grid by their map coordinates.

DataFrame `billboards` (from `billboards.csv`) has columns `board_id` (primary key), `east`, and `north` — the grid coordinates of each billboard.

Two billboards can serve as the opposite corners of an axis-aligned rectangular plot only if their east coordinates differ AND their north coordinates differ. For every such pair report `b1` (the smaller `board_id`), `b2` (the larger `board_id`), and the `plot_area` enclosed, computed as the absolute east difference times the absolute north difference. Order the result by `plot_area` descending, then by `b1` ascending, then by `b2` ascending.

Input data

Example rows — the live problem includes the full dataset.

billboards
board_ideastnorth
127
248
3210

Expected output

Your answer should return 2 rows with the columns b1, b2, plot_area.

Starter code (Pandas (Python))

import pandas as pd

def billboard_plot_pairs(billboards) -> pd.DataFrame:
    # Your code here
    return billboards

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