Back to questions

Top-K rows per group in Pandas

Given a DataFrame with user_id, item_id, and score, how would you keep the 50 highest-scoring items for every user?

Answer as you would in an interview

Answer aloud or write down a few key points. The text field is optional; the review opens after your attempt.

Loading
Top-K rows per group in Pandas — interview question — ML Mentor