I have a non-indexed data frame with over 50000 lines read from a csv file as follows:
John Mullen 12/08/1993 Passw0rd
Lisa Bush 06/12/1990 myPass12
Maria Murphy 30/03/1989 qwErTyUi
Seth Black 21/06/1991 LoveXmas
I would like to validate each cell of each row against a specific regular expression:
- validate the password with the
PassRegexbelow - validate First name/ last Name with the
NameRegexbelow - etc...
and then move the rows where any of the cells do not validate to a new data frame.
import re
PassRegex = re.compile(r"^(?!.*\s)(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,50}$")
NameRegex = re.compile(r"^[a-zA-Z0-9\s\-]{2,80}$")
For example in this case, the below rows wouldn't validate with the PassRegex, so I want to move them to a separate data frame:
Maria Murphy 30/03/1989 qwErTyUi
Seth Black 21/06/1991 LoveXmas
Is there a way to do this without iterating through the whole data frame row by row, and cell by cell?
Any help is much appreciated.