there!
I have a dataframe and I want to extract cellphone numbers.
VARIAVEL
Telefone:(11) 95262-7297
Celular:(31) 97250-8639
Não possui
Below is the code which I'm using to do it:
df['TELEFONE'] = df['VARIAVEL'].apply(lambda x: re.search('\(\d\d\)\s\d\d\d\d\d-\d\d\d\d', x).group(0) if pd.notnull(x) else x )
The erros which is returning is:
AttributeError: 'NoneType' object has no attribute 'group'
I know the error is because 'Não possui' returns no match, and due to it I can't use 'group(0)'.
How can I fix it? How can I apply regex and group(0) just on matched cases?