Premium problem72. One-Hot Encode a Multi-Value Column

Medium Locked

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.

Input

                tags
0      python:pandas
1         pandas:sql
2             python
3  sql:python:pandas

Output

   pandas  python  sql
0       1       1    0
1       1       0    1
2       0       1    0
3       1       1    1

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)