String manipulation
\s
matches whitespace (spaces, tabs and new lines)
str.match
pattern = r'^[a-zA-Z][a-zA-Z0-9_.-]*@leetcode\.com$'
# Filter valid emails
df = users[users['mail'].str.match(pattern, na=False)]
-
Series.str.lower
: Converts all characters to lowercase.Series.str.upper
: Converts all characters to uppercase.Series.str.title
: Converts first character of each word to uppercase and remaining to lowercase.Series.str.capitalize
: Converts first character to uppercase and remaining to lowercase.Series.str.swapcase
: Converts uppercase to lowercase and lowercase to uppercase.Series.str.casefold
: Removes all case distinctions in the string.