← All Python interview questions
Top-selling product in every city
HardPandas — GroupByFlipkartWalmart
Category managers want the single best-selling product per city by revenue — the pandas equivalent of a ROW_NUMBER() window function.
Write a function top_product(df) that returns a dictionary mapping each city to the product with the highest total amount in that city. When two products tie, return the one that comes first alphabetically.
More Pandas — GroupBy questions
Asked at Flipkart
Practising alone only goes so far — our live cohorts pair Python and Pandas depth with dashboards, agentic analytics projects and mock interviews.
Explore the program