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
Data Manipulation (SQL/Python)
Data Scientist
TikTok
November 29, 2026
Data Scientist
Online Assessment
Data Manipulation (SQL/Python)
Easy

0

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
pandas explode
list columns
normalization
groupby ranking
trend detection
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. 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 Problems
Sample Answer
Clarify the Data
  • videos(video_id, post_date, hashtags), hashtags is a Python list or None.
  • #FYP and #fyp are the same tag. A caption repeating #dance twice 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...


Submit Your Answer
Markdown supported