Top Hashtags per Day From Exploded Caption Tag Lists
Last updated: November 29, 2026
Quick Overview
Given a videos DataFrame where hashtags is a list column (sometimes empty or null, with mixed case and repeats), return the top k hashtags per posting day by number of videos using them.
TikTok
November 29, 20260
0
0 solved
Given a videos DataFrame where hashtags is a list column (sometimes empty or null, with mixed case and repeats), return the top k hashtags per posting day by number of videos using them.
Hashtag challenges and trends like #BookTok are central to how content spreads on TikTok, and trend dashboards start from counts like these. The interviewer checks list-column handling with explode, normalization, per-video dedup, and deterministic tie-breaking.
What the Interviewer Expects
- Use explode on the list column and handle null or empty lists
- Normalize case and the leading #
- Count each tag once per video
- Rank within day with a deterministic tiebreaker
- Return a tidy long table
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 find tags that are trending (growing fast) rather than just popular?
- How would you exclude generic tags like #fyp that appear on most videos?
- How would you do the same in SQL with an array column?
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
videos(video_id, post_date, hashtags),hashtagsis a Python list or None.#FYPand#fypare the same tag. A caption repeating#dancetwice counts once for that video.- Ties broken alpha...
Approach
Replace null lists with empty lists, explode, drop the NaN rows that empty lists produce, normalize, dedupe on (video_id, tag), count per day and tag, sort by count descending then tag, and number...