Collapse Duplicate Product Listings Within a Brand by Normalized Title
Last updated: November 29, 2026
Quick Overview
Sellers sometimes create multiple ASINs for the same product. Given a pandas DataFrame of listings (asin, brand, title, created_at), normalize brand and title, group listings that are the same product within the same brand, and map every ASIN to the oldest ASIN in its group as the canonical listing.
Amazon
November 29, 20260
0
0 solved
Sellers sometimes create multiple ASINs for the same product. Given a pandas DataFrame of listings (asin, brand, title, created_at), normalize brand and title, group listings that are the same product within the same brand, and map every ASIN to the oldest ASIN in its group as the canonical listing.
Catalog quality teams at Amazon merge duplicate detail pages so customers see one listing with all offers and reviews. In a technical screen this tests pragmatic text normalization, choosing a deterministic canonical record, and groupby transform, plus judgment about where exact-key matching stops being enough.
What the Interviewer Expects
- Normalize brand (trim, case) and title (case, punctuation, noise words) into a match key
- Make the key order-insensitive so reordered titles match
- Choose the canonical record deterministically (oldest, then ASIN as tie-break)
- Use groupby transform to broadcast the canonical ASIN to every row
- Discuss false merges such as different wattages and how the key protects them
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you catch near-duplicates such as typos that an exact key misses?
- Why is grouping within brand important, and when could it miss real duplicates?
- How would you validate precision of the merges before applying them to the live catalog?
- How would you scale this to hundreds of millions of listings?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
listings(asin, brand, title, created_at). Brands vary in case and whitespace; titles vary in punctuation, word order and marketing noise like "NEW".- Two listings are the same product if, within ...
Approach
- Brand key: strip and lower-case.
- Title key: lower-case, replace punctuation with spaces (so
USB-CandUSB Cboth becomeusb c), drop a small noise vocabulary, sort tokens and join. Sorting...