Home > Back-end >  I want to see how many times a word appears in every cell (CSV)
I want to see how many times a word appears in every cell (CSV)

Time:03-13

This is how my data looks:

This is how my data looks

I want to see how many times a word appears in every posts cell.

e.g. In the 3rd row, the word personality occurred 2 times.

This is my code:

This is all I have

CodePudding user response:

It's simple. Just use .str.count:

df['personality_count'] = df['posts'].str.count('personality')
  • Related