I have a dataframe as shown:
Name Email Phone
Mohan [email protected] AAASWS
Shubham [email protected] 1234567889
Sohail [email protected]
Suresh [email protected] 9821345123
Kashi [email protected] Kshgatr
Now the phone column should contain phone numbers of individuals.
But here it is observed that it contains some missing values and also some garbage string values
I want to filter these values and label them as "Rectify" in the resultant Dataframe
Hence df should be as given
Name Email Phone
Mohan [email protected] Rectify
Shubham [email protected] 1234567889
Sohail [email protected] Rectify
Suresh [email protected] 9821345123
Kashi [email protected] Rectify
CodePudding user response:
Use to_numeric
and fill NaN
values
pd.to_numeric(df.Phone, errors='coerce').fillna('Rectify')