Count Tags in Multi-Valued Columns

easy
Unit 4 · Pandas I0/3 to milestone

Survey and CRM exports often cram several values into one cell: "Python, SQL , python".

df has an id column and a tags column of comma-separated strings (which may be empty or NaN). Implement:

  • tag_counts(df): a pd.Series mapping each tag to the number of rows containing it. Tags are stripped and lowercased, empty tags are dropped, and a tag repeated within one row counts once. Sort by count descending, then tag alphabetically.
  • cooccurrence(df): a dict mapping (a, b) with a < b to the number of rows containing both tags
#pandas#strings#cleaning2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Count Tags in Multi-Valued Columns · TechGradify