March 2020
Beginner to intermediate
352 pages
8h 40m
English
We noticed that the from field contains more information than we need. We just need to extract an email address from that field. Let's do some refactoring:
import re
def extract_email_ID(string): email = re.findall(r'<(.+?)>', string) if not email: email = list(filter(lambda y: '@' in y, string.split())) return email[0] if email else np.nan
The preceding function is pretty straightforward, right? We have used a regular expression to find an email address. If there is no email address, we populate the field with NaN. Well, if you are not sure about regular expressions, ...
Read now
Unlock full access