Best click-through rates

MediumPinterestpivot_tablefill_valueratiostop N· 20 XP

Each row of ad_events.csv is one impression, click or checkout for an ad campaign. The ads team ranks campaigns by click-through rate (CTR): clicks divided by impressions.

Store the 5 campaigns with the highest CTR, with columns campaign_id, impressions, clicks and ctr (rounded to 3 decimals), highest CTR first.

Expected answer

Store your answer in result.

  • Exactly 5 rows, in order

Hints, the later steps and the answer come with Pro.

import pandas as pd

events = pd.read_csv("ad_events.csv")
result = ...