In the function you are iterating
for x in df['Name1']
. This will loop over every value in the Name1
column of the data frame. I think you should post your question on Code Review Stack Exchange which is more geared toward helping new programmers learn to program and write better code. — augurar 43 secs ago