Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs
What is the total number of ad impressions each ad received in ads_actions, treating each row as a single impression regardless of clicked_ad? Return ad_name and ad_impressions, grouped by ad_name, and order the results by ad_impressions descending, then ad_name ascending.
| Column Name | Type |
|---|---|
| ad_exp_id | int64 |
| ad_name | object |
| cpc_rate | object |
| clicked_ad | int64 |
| Column Name | Type |
|---|---|
| ad_name | object |
| ad_impressions | int64 |
Output columns: ad_name, ad_impressions
Count rows; ignore clicked_ad values
Sort impressions DESC, name ASC
Treat every row in ads_actions as one impression; don’t use clicked_ad at all.
Group by ad_name and count rows per group (SQL: COUNT(*); pandas: groupby(...).size() or count()).
After aggregating, sort by impressions descending, then ad_name ascending to break ties.