Justin
Justin

Reputation: 73

Dataframe: Clean cells containing specific value

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!

Upvotes: 2

Views: 97

Answers (1)

U13-Forward
U13-Forward

Reputation: 71610

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.

Upvotes: 1

Related Questions