py - count if a word is present in a column code example
Example: py - count if a word is present in a column
words = 'one two three'.split()
df.assign(counts=df.texts.str.count('|'.join(words)))
texts counts
0 throne one 2
1 bar one 1
2 foo two 1
3 bar three 1
4 foo two 1
5 bar two 1
6 foo one 1
7 foo three 1
8 one three 2