validate_email: to Validate email
Validate Email , more on apply() here.
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
ModuleNotFoundError: No module named 'validate_email'
then you have to install validate_email module.
pip install validate_email
Inside Anaconda goto Environment
at your left side navigational menu
Middle you can see Base root
From Base root select Open Terminal
You will reach the Anaconda terminal where you can install any package .
« Pandas
« Pandas DataFrame
contains() to display and delete row based on Conditions »
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com