Reputation: 119
I'm trying to start the Riiid Answer Correctness Prediction, and I got stuck in a very early phrase.
I would need to iterate over 'tags' column and count occurrences of each tag.
How do I extract, explode or change 'tags' values so that I could use value_counts() or apply(eval)?
Upvotes: 0
Views: 241
Reputation: 14216
You can actually achieve this with one line using pd.Series.str
and pd.Series.explode
.
df.tags.str.split().explode().value_counts()
131 5
162 4
38 2
36 1
29 1
81 1
149 1
5 1
51 1
92 1
101 1
Upvotes: 1