I am trying to validate phone numbers in a dataframe

I am trying to validate the Phone number in my dataframe. The code should flag the number as home or Mobile or Invalid

This is specific to UK phone number validation. And i tried Regex but it wont flag the number.


import pandas as pd 
import re
# display(df)
# df.head()
df['Phonenumber']=df(df.withColumn('Phone_Number_Validity', if(isValid(df)):       
       # print ("Mobile Number")      
       else : 
       # print ("Home Number")))
display(df) 


Getting Syntax error



Not the answer you're looking for? Browse other questions tagged python pandas dataframe azure-databricks or ask your own question.