117. One-Hot Encode a Multi-Value Column

Medium

Column tags holds colon-separated tags per row (e.g. "python:pandas"). Return a one-hot-encoded DataFrame with one column per distinct tag (columns sorted alphabetically) and one row per original row, with a 1 where that row has the tag and 0 otherwise.

Sample data: df:

                tags
0      python:pandas
1         pandas:sql
2             python
3  sql:python:pandas
Implement solve(...)