Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas: split string, and count values?

df['word_count'] = df['string'].str.split(';').str.len()
df

     string  word_count
id                     
0   31672;0           2
1   31965;0           2
2   0;78464           2
3     51462           1
4   31931;0           2
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #split #count
ADD COMMENT
Topic
Name
5+5 =