Open
Description
Instance of the original version
df_john = df['Name'].str.contains("John", regex=False)
df_helen = df['Name'].str.contains("Helen", regex=False)
Instance of the faster version
ls_john = []
ls_helen = []
# Do a single pass over the strings
for s in df['Name']:
ls_john.append("John" in s)
ls_helen.append("Helen" in s)
ls_john = pd.Series(ls_john)
ls_helen = pd.Series(ls_helen)