0

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. enter image description here

How do I extract, explode or change 'tags' values so that I could use value_counts() or apply(eval)?

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.