0

For instance I have data similar to this

      name                    flag               seen_week_end
0    Mick Am Johnson         TRUE                 03/05/2017
1    Brian Ma Yeager          FALSE                 NaN
2    Maggie Alvarez       FALSE                NaN
3    Christine Ma Yin           FALSE                NaN

In the above dataframe I want to replace the word in name column

Am as Yan
Ma as Mu   

How to use dictionary and replace?

1 Answer 1

2

Here is replace

df['name']=df['name'].replace({r'\bAm\b':'Yan',r'\bMa\b':'Mu'},regex=True)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.