How would you compute a top-N per group in pandas?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
Overview: Asks how to return the N rows with the largest value in each group of a pandas DataFrame. It tests vectorized groupby methods, deliberate handling of ties at the cutoff, missing values and small groups, and the performance cost of applying a function to each group.