Reviewed by Aditya Kumar · Last reviewed 2026-03-24
**Pandas:** total = df['amount'].sum(); top_users = df.groupby('user_id')['amount'].sum().nlargest(5); most_purchased = df['product_id'].value_counts().index[0]. **SQL:** SUM, GROUP BY + ORDER BY + LIMIT. For top-5: ROW_NUMBER() or RANK() OVER (PARTITION BY 1 ORDER BY total...
Pandas: total = df['amount'].sum(); top_users = df.groupby('user_id')['amount'].sum().nlargest(5); most_purchased = df['product_id'].value_counts().index[0].
SQL: SUM, GROUP BY + ORDER BY + LIMIT. For top-5: ROW_NUMBER() or RANK() OVER (PARTITION BY 1 ORDER BY total DESC).
Scalability: For Myntra-scale: run in warehouse (Snowflake/BigQuery)—push compute. Pre-aggregate user totals in summary table for fast top-N.
total = df['amount'].sum()
top_users = df.groupby('user_id')['amount'].sum().nlargest(5)
most_purchased = df['product_id'].mode().iloc[0]
Red Flag: Using apply for aggregation. Pro-Move: 'We materialize user_totals daily—top-N query runs in ms.'
According to DataEngPrep.tech, this is one of the most frequently asked Python/Coding interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.