Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Python :: django composite primary key 
Python :: pandas como quitar comillas simples de una columna 
Python :: int to hex python without 0x 
Python :: python redirect with button click 
Python :: nested for loop table python 
Python :: download images off unsplash python 
Python :: max between two numbers python 
Python :: return mean of df as dataframe 
Python :: python check if object is empty 
Python :: manage python environment in jupyterlab 
Python :: ranking 
Python :: turtle graphics documentation 
Python :: how to make a comment in python 
Python :: handwritten digits data set 
Python :: python slicing 
Python :: mongodb in python 
Python :: python change function of object 
Python :: scikit learn to identify highly correlated features 
Python :: pyspark average group by 
Python :: matrix diagonal sum leetcode 
Python :: pytube python 
Python :: how to declare private attribute in python 
Python :: login url 
Python :: python os get dir path 
Python :: #remove a sublist from a list-use remove method 
Python :: string python 
Python :: pandas fillna with none 
Python :: hist pandas 
Python :: tkinter canas can you use other fonts 
Python :: drf serializer general validate method 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =