0

How to iterate through the email column(x) with the lines below

validate_email(x, check_mx=True)
validate_email(x, verify=True)

#pip install pyDNS
#pip install validate_email

import pandas as pd 
from validate_email import validate_email

# initialize list of lists
data = [['[email protected]','True','True'], ['[email protected]','True','False'], ['[email protected]','False','False']]
 
# Create the pandas DataFrame
df = pd.DataFrame(data, columns=['email', 'check_mx', 'verify'])
 
# print dataframe.
df

Output should look like the image below:

enter image description here

1 Answer 1

1

There is a package for that:

from validate_email import validate_email
df['is_valid_email'] = df['email'].apply(lambda x:validate_email(x))

This will create a column with a value if the email address is valid

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.