Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

dataframe string find count

In [21]: df = pd.DataFrame(['hello', 'world', 'hehe'], columns=['words'])

In [22]: df.words.str.count("he|wo")
Out[22]:
0    1
1    1
2    2
Name: words, dtype: int64

In [23]: df.words.str.count("he|wo").sum()
Out[23]: 4
Comment

PREVIOUS NEXT
Code Example
Python :: install python in docker file 
Python :: how to logout in django 
Python :: how to set variable to null in python 
Python :: intersection() Function of sets in python 
Python :: flask print to console 
Python :: validity of password in python 
Python :: discord.py reference 
Python :: python how to delete a directory with files in it 
Python :: How to convert string date to datetime format in python 
Python :: how to make a button in python turtle 
Python :: herencia python 
Python :: remove all rows with at least one zero pandas 
Python :: python find index of first matching element in a list 
Python :: find sum of factors of a number python 
Python :: python start with 
Python :: python substring count 
Python :: python script as service linux 
Python :: np.zeros((3,3)) 
Python :: install python 3.8 
Python :: python for character in string 
Python :: extends template django 
Python :: django include 
Python :: random int python 
Python :: django slug int url mapping 
Python :: Python, importing other scripts from other directories 
Python :: python is inf 
Python :: python not equal 
Python :: how to take input for list in one line in python 
Python :: python append value to dictionary list 
Python :: detect character in string python 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =