regex for pandas code example
Example 1: pandas show column with regular expression
import numpy as np
df['first_five_Letter']=df['Country (region)'].str.extract(r'(^\w{5})')
df.head()
Example 2: pandas show column with regular expression
# Total items starting with F
S.str.count(r'(^F.*)').sum()
Example 3: pandas show column with regular expression
df[df['Country (region)'].str.count('^[pP].*')>0]