import pandas as pd
from validate_email import validate_email
my_email={'email':['Ravi','abc@example.com','Alex',
'Ron.23@my_domain.com']}
df = pd.DataFrame(data=my_email)
df['valid_email'] = df['email'].apply(lambda x:validate_email(x))
print(df)
print(df[df['valid_email']]) # only valid emails ...
Output
email valid_email
0 Ravi False
1 abc@example.com True
2 Alex False
3 Ron.23@my_domain.com True
email valid_email
1 abc@example.com True
3 Ron.23@my_domain.com True
If you are getting error saying pip install validate_email
Inside Anaconda goto Environment at your left side navigational menu
Base root Open Terminal
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.