pandas dataframe regex code example

Example 1: pandas show column with regular expression

S=pd.Series(['Finland','Colombia','Florida','Japan','Puerto Rico','Russia','france'])
S.str.contains('^F.*')

Example 2: how to apply regex to pandas column

import re
#a string
str = '{63_:_foo},,bar,_mango_,apple'
#split string into chunks
chunks = re.split('[{_}:,][_,]',str)
#print chunks
print(chunks)

Example 3: pandas show column with regular expression

S=pd.Series(['Finland','Colombia','Florida','Japan','Puerto Rico','Russia','france'])
[itm[0] for itm in S.str.findall('^[Ff].*') if len(itm)>0]