I have this dataframe:
| Name | Phone / Mail |
|---|---|
| Max | 0176348334 |
| Celine | [email protected] |
| ... | ... |
How do I edit all the cells containin "@"?
So the result should be like this:
| Name | Phone / Mail |
|---|---|
| Max | 0176348334 |
| Celine | Please fill in Phone Number |
| ... | ... |
Thank you!
CodePudding user response:
Use loc:
df.loc[df['Phone / Mail'].str.contains('@'), 'Phone / Mail'] = 'Please fill in Phone Number'
Or np.where:
df['Phone / Mail'] = np.where(df['Phone / Mail'].str.contains('@'), df['Phone / Mail'], 'Please fill in Phone Number')
Just filter the occurrences of the @ sign.
