Practice / strings dates nulls

Tag Explosion

medium

A blog platform stores each post's tags as a comma-separated string (e.g. "spark,python"). The team wants a tag leaderboard.

posts

Your task: return each individual tag and uses — how many posts use it.

Assign your answer DataFrame to result. Row order doesn't matter.

postsinput DataFrame

Schema
columntype
post_idlong
tagsstring
Sample rows
post_idtags
1spark,python
2python
3spark,rust
Expected output shape
taguses· 3 rows
Hint

F.split(F.col("tags"), ",") turns the string into an array; F.explode(...) makes one row per element. Then groupBy("tag") and count("*").

Lesson refresher

This problem builds on Reshaping Data (~7 min). Pop it open in a new tab if you want a quick recap.

Loading editor…
Hit Run to execute your code and see the output here.