This is auxiliary to this post: Is there better way to iterate over nested loop for rows (30000)?
I would like to find rows in following table, which contain non dutch bank numbers. I create an extra column in the dataframe in the following code with value 'ja', when a bank number is not dutch, i.e. it does not contain characters 'NL'. Any better ways to loop over the rows?
import pandas as pd
import re
data={'IBAN':['NLAMRO123456789','NLINGB126656723','BGFFEO128856754','NLAMRO123896763','DUDMRO567456722','NLRABO123456712']}
df=pd.DataFrame(data)
df['No Dutch Bank']=None
substring='NL'
row_count=len(df.index)
for i in range (0, row_count):
mainstring=df['IBAN'][i]
if re.search(substring, mainstring) is None:
df['No Dutch Bank'][i]='ja'
df.head()
So far I have reached to this expression after browsing through internet:
df['No Dutch Bank'] = list(map(lambda x: "None" if x else 'ja', (re.search('NL', x))))