Pandas Data Frame, I would like to loop over the column named 'first' to verify if is an email or not, if is an email remove it and leave that cell blank.
I have try
for x in df['first']:
if '.com' in x:
x = ''
CodePudding user response:
Answering the pandas
portion of this, since that's not exactly email verification.
Use .map
with a lambda
function for this. This is the preferred way to do what you are trying to do in pandas, instead of iterating.
df['email'] = df['email'].map(lambda x: x if '.com' in x else '')